You are here: Home Tech Postgres, psycopg2, virtualenv install hints

Postgres, psycopg2, virtualenv install hints

by Chris Shenton last modified Feb 08, 2010 05:20 PM
Had problems with Darwin ports, homebrew install, etc etc. Put Postgres's binary directory in your PATH before trying to install psycopg2.

I had Postgres (postgresql) installed by Darwin port and it was fine. But when I tried to install psycopg2 (for a Django project) it failed trying to find some libraries.

I then tried to use the 'homebrew' port installer mechanism and I couldn't get it to build Postgresql itself.

Building postgres is not hard by hand, so I did that, and it installs in /usr/local/pgsql.

I have a virtualenv based on my hand-installed /usr/local/python/2.6.4.

When I tried to pip install or even manually install I got cryptic errors:

(sunra)chris:psycopg2-2.0.13$ python setup.py build_ext
running build_ext
error: No such file or directory

Uh, *what* is the missing file? Turns out I just needed to put the Postgres bin directory on the PATH:

(sunra)chris:psycopg2-2.0.13$ export PATH=/usr/local/pgsql/bin:$PATH
(sunra)chris:psycopg2-2.0.13$ pip install -U psycopg2
Downloading/unpacking psycopg2
  Downloading psycopg2-2.0.13.tar.gz (258Kb): 258Kb downloaded
...
Successfully installed psycopg2

Share this: