Install psycopg2 inside a virtualenv environment

To be able to install psycopg2 (python postgresql driver) inside a virtualenv environment, you need to install these packages first:

$ sudo apt-get install libpq-dev python-dev

or you will get this error:

With those packages installed, you can now install psycopg2 in virtualenv:

(myvenv) $ pip install psycopg2