When you try to install psycopg2 in your virtualenv via pip you will most likely end up with the following error:
The first thing to do is not to panic. You can resolve this error by installing two packages. Just run the following command:
$ sudo apt-get install libpq-dev python-dev
If the installation fails, and you get a notice about certain packages not being found just run the following command to update the local package index:
$ sudo apt-get update
Then try to install the libpq-dev and python-dev packages one more time.
After the packages are successfully installed, activate your virtual environment and proceed with the installation:
$ workon ENV (ENV)$ pip install psycopg2
That should take care of the issue and allow you to do whatever it is you need to do with Postgres.