Installing psycopg2 into virtualenv when PostgreSQL is not installed on development system

apt-get install libpq-dev

helped me on debian squeeze


psycopg depends on pg_config command, and if you don't have it, you can't install psycopg.

If system installation is a problem to you, why don't you try compiling PostgreSQL and including generated bin files in your $PATH? Like:

export PATH=/path/to/compiled/postgresql/bin:"$PATH"
pip install psycopg2

brew install postgresql

export LDFLAGS="-L/usr/local/opt/openssl/lib"

export CPPFLAGS="-I/usr/local/opt/openssl/include"

pip3 install psycopg2