Installing from source code

Download and unpack the archive, then run from the unpacked directory:

python setup.py install

Your system must be able to compile a C Python extension against the libpq library: you will probably need python-dev and libpq-dev packages.

The pg_config must be available in your path, or alternatively you must specify its full path in the setup.cfg file.

Installing from PyPI

Psycopg is available on the Python Package Index: You can install it with:

pip install psycopg2

You will still need the packages mentioned in Installing from source code in order to install Psycopg.

Installing on Mac OS X

As a first option, please consider using a packaged version of Psycopg from Fink or MacPorts.

If you still want to build Psycopg from source, take a look at these articles.

Installing on Windows

If you want to build on Windows yourself, here is an article with some tips. Building using Microsoft compilers is supported as well.

Jason Erickson's Windows port of Psycopg is still probably the best experience.

Travis Krause has made Jason's packages pip-windows-friendly: you can do for instance:

pip install -e git+git@github.com:nwcell/psycopg2-windows.git@win64-py33#egg=psycopg2

Choose between win32 or win64 and your Python version: see https://github.com/nwcell/psycopg2-windows for more details.