user3125823 user3125823 - 5 months ago 58
Python Question

Best way to install psycopg2 on ubuntu 14.04

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 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 psycopg you installed through apt-get is not visible from inside the virtual env.

You should install it through pip

pip install psycopg2

after sourcing your environment.