11👍
This is an error that crops up when the build tools cannot find your Postgresql libraries. It means one of three things:
-
You don’t have postgresql installed on your system. If so, download and build postgres, or download a pre-built psycopg2 binary for OS X.
-
You have postgresql installed on your system, but you installed from a binary package and therefore don’t have the necessary libraries that psycopg2 needs. In this case, download and build postgres.
-
More commonly, though, this means that you have built postgres on your system and just need to instruct psycopg2 how to find the
pg_config
binary so that it can configure the compilation. Either:a. put the path to pg_config in your shell path (it’s usually at
/usr/local/pgsql/bin/
if you built postgres from source using the defaults.b. or, edit the
setup.cfg
file in the psycopg2 source folder and provide the full path topg_config
on the line that starts withpg_config=
. Be sure to uncomment this line by removing the hash symbol at the front. If you built postgres using the defaults, the line will look something like:pg_config=/usr/local/pgsql/bin/pg_config
- [Django]-Django inline – allow adding disable editing
- [Django]-Django-compressor + less compress the files but link to original files
- [Django]-Where to delete model image?
- [Django]-How to add a new instance of Django model with FileField by ModelForm?
- [Django]-Django user in tornado
0👍
I needed to install the psycopg2 library only in a virtualenv without adding it to the root python and I didn’t want to fully install postgreSQL on my local machine so I came up with this solution which seems to work really well.
-
Download the postgres.app from here, and drop the app in the Applications folder.
-
In a shell, add the postgres.app bin directory to the PATH:
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.3/bin
- Activate the virtualenv:
. myvenv/bin/activate
- pip install psycopg2
I tried setting the pg_config variable but that didn’t work. The pip install specifically told me that I had to put the directory where pg_config was located in the path.
I also kinda prefer this solution because, if I want to run PostgreSQL locally, I can easily just start up the app and then close it when I’m done and it’s gone — nothing left running in the background. No system config changes or anything. It is a great way to run PostgreSQL for local development or a quick demo.
- [Django]-Django get current view in template
- [Django]-Adding hours and days to the python datetime
- [Django]-Django CreateView : Append ForeignKey to CustomForm Data