How to install pygresql in virtualenv?

1.1k views Asked by At

when I try to install it via pip, or easy_install, it gives me error:

OSError: [Errno 2] No such file or directory: '/usr/include/pgsql/server'

How should I do this correctly?

2

There are 2 answers

7
math On BEST ANSWER

You don't have the PostgreSQL server include files or they are not located at the expected path on your system. See PyGreSQL Installation for more details on PyGreSQL compilation.

For example, on Ubuntu, you need to install postgresql-server-dev-all package to have server include files. On Fedora, it's postgresql-devel.

Usually, pip will then use pg_config to find the correct path for these files.

$ pg_config --includedir-server
/usr/include/postgresql/9.1/server

Based on your error, pg_config has returned '/usr/include/pgsql/server' as the location of server header files but they have not been installed on your system.

0
Burhan Khalid On

You need to install the build dependencies for the package.

In Debian-baseds operating systems, this would be:

sudo apt-get build-dep psycopg2

You should also install the build-essentials package (if not already installed). Then you can continue with the virtualenv installation.