14 de junio de 2011

Installing psycopg2 inside a virtualenv in Mac OS X

If you tried to install psycopg2 inside a virtualenv in Mac OS X and got something like this:

(Env)MacBookPro:proj matias$ ARCHFLAGS="-arch i386 -arch x86_64" pip install --upgrade psycopg2
Downloading/unpacking psycopg2
  Downloading psycopg2-2.4.2.tar.gz (666Kb): 666Kb downloaded
  Running setup.py egg_info for package psycopg2
    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'.
    Complete output from command python setup.py egg_info:
    running egg_info
creating pip-egg-info/psycopg2.egg-info
writing pip-egg-info/psycopg2.egg-info/PKG-INFO
writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
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'.
----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in /Users/matias/.pip/pip.log

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


That got it fixed for me:
export PATH=/Library/PostgreSQL/8.4/bin/:"$PATH"
Now, let's go again:



(Env)MacBookPro:proj matias$ ARCHFLAGS="-arch i386 -arch x86_64" pip install psycopg2
Downloading/unpacking psycopg2
  Running setup.py egg_info for package psycopg2
    no previously-included directories found matching 'doc/src/_build'
Installing collected packages: psycopg2
 (....lot's of lines of output here....)
Successfully installed psycopg2
Cleaning up...
Done!

2 comentarios:

Anónimo dijo...

thanks! you just helped me :)

Matías dijo...

:)