I am having trouble installing a Django app (Mezzanine) on Ubuntu 14.04. I've installed most necessities using apt-get (except for django-compressor and south -used pip), including psycopg2 for Postgres. However when I go to run python manage.py createdb it gives this error:
Error loading psycopg2 module: No module named psycopg2
This is the command I'm using to install psycopg2:
sudo apt-get install python-psycopg2
What am I doing wrong? Should I use pip to install psycopg2. I went to the website and it recommends installing through your OS package manager instead of pip.
I am working in a virtualenv except for when I am installing the psycopg2 elements....
The psycopg2-binary package is meant for beginners to start playing with Python and PostgreSQL without the need to meet the build requirements. If you are the maintainer of a published package depending on psycopg2 you shouldn't use psycopg2-binary as a module dependency.
psycopg2-binary and psycopg2 both give us the same code that we interact with. The difference between the two is in how that code is installed in our computer.
Psycopg is the most popular PostgreSQL database adapter for the Python programming language. Its main features are the complete implementation of the Python DB API 2.0 specification and the thread safety (several threads can share the same connection).
If you need psycopg2 for a system installed program, then install it with the system package manager. If you need it for a program in a virtualenv, install it in that virtualenv.
. env/bin/activate
pip install psycopg2
Note that on many distros, the development headers needed for compiling against libraries are not installed by default. For psycopg2 on Ubuntu you'll need the python and postgresql headers.
sudo apt-get install python-dev libpq-dev
psycopg 2.7 now issues a warning that it will stop providing binary releases due to compatibility issues.
The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: http://initd.org/psycopg/docs/install.html#binary-install-from-pypi.
See the release announcement for a thorough explanation. To handle the warning, tell pip not to download the pre-built wheel for psycopg2.
pip install --no-binary psycopg2 psycopg2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With