9

I'm trying to install psycopg2 in cygwin but have not succeeded yet. The error is:-

Gaurav@gauravpc ~/FieldAgentWeb/FieldAgentWeb
$ easy_install psycopg2
Searching for psycopg2
Reading http://pypi.python.org/simple/psycopg2/
Reading http://initd.org/psycopg/
Reading http://initd.org/projects/psycopg2
Best match: psycopg2 2.4.2
Downloading http://initd.org/psycopg/tarballs/PSYCOPG-2-4/psycopg2-2.4.2.tar.gz
Processing psycopg2-2.4.2.tar.gz
Running psycopg2-2.4.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-QBYpxH
/psycopg2-2.4.2/egg-dist-tmp-gcLa5F
Error: pg_config executable not found.

Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:

    python setup.py build_ext --pg-config /path/to/pg_config build ...

or with the pg_config option in 'setup.cfg'.
error: Directory not empty <built-in function rmdir> /tmp/easy_install-QBYpxH/ps
ycopg2-2.4.2/tests

After that i was trying to get d pg_config file, but couldn't find it on the net.

Lance Roberts
  • 22,383
  • 32
  • 112
  • 130
himanshu
  • 1,990
  • 3
  • 18
  • 36

2 Answers2

16

I just managed to install psycopg2 today without installing the windows PostgreSQL (in my case the db is already set up in another server, I just need to connect to it with a python package which depends on psycopg2, so having the complete installation it was not necessary for me).

Following pg_config executable not found , from the cygwin setup I installed postgresql-devel AND libpq-dev ( those should be the necessary ones, for the record I installed also a lot of other packages relative to postgresql like postgresql-client, postgresql-plpython and libpq5).

After that I could run succesfully pip install psycopg2

Community
  • 1
  • 1
lib
  • 2,918
  • 3
  • 27
  • 53
  • I just tested this with cygwin/babun and pact installs. `libpq-devel` was the one. `postgresql-devel` was not needed. – juanitogan Feb 06 '16 at 22:14
  • 1
    I was having a pg_config not found issue in Cygwin, after installing postgresql-devel and libpq-devel, it is now present! Thank you. – Craig London Oct 13 '16 at 23:12
  • I was trying to install `pgcli` package but it was failing on building wheel for `psycopg2`. After installing packages mentioned by you it was installed correctly. Now I have other error when running `pgcli` but this is different story... – Wirone Jul 14 '17 at 10:06
5

pg_config is part of your PostgreSQL installation. It's in the bin directory of your local installation (e.g. C:\Program Files (x86)\PostgreSQL\9.0\bin). Add that directory to your search path and try to build again.

Pablo
  • 8,644
  • 2
  • 39
  • 29
  • Your solution will be helpful in d case when someone is using direct installation of POSTgreSQL. But I m using POSTgreSQL(which is already installed in django) with django.So there is no such directory(e.g. C:\Program Files (x86)\PostgreSQL\9.0\bin) in my c: drive. – himanshu Oct 03 '11 at 05:29
  • I just downloaded the official django distribution and it *doesn't* include PostgreSQL, everything on the net says you should download and install it separately. In any case... if PostgreSQL is installed with your copy of django, just look for pg_config in your django installation directory. – Pablo Oct 03 '11 at 05:35
  • Pablo is in fact correct. In order to be able to install psycopg2 ***you need to have a separate installation of PostgreSQL*** (aside -- *PostgreSQL* is the correct capitalization). Django does not come with DB drivers, let alone a DB. – cwallenpoole Oct 03 '11 at 06:10