Sunday, 10 November 2013

Install psycopg2 with Postgresql

psycopg2 is a driver in python to connect python application with postgresql.

Install library in python, normal is easy with pip, easy_install but with psycopg2, I met errors in all linux and window.

With window, I can use this option:
http://tientuts.blogspot.com/2013/10/fix-some-errors-when-install-library.html

but with linux, when I install, this is a very common error:

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 in /tmp/pip-build/psycopg2


After search google and try, this is my solution (in Centos):
Install postgresql in here: https://wiki.postgresql.org/wiki/Detailed_installation_guides
In present, the newest version of postgresql is 9.3 and we need setup PATH value for postgresql

PATH=$PATH:/usr/pgsql-9.3/bin/
pip install psycopg2


No comments:

Post a Comment