CentOS - manually installed python with Postgresql lib(psycopg2)

1 minute read

$ easy_install psycopg2 (or python setup.py install or pip install psycopg2…. etc)

running build_ext 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’.

 

$ find / -name pg_config

you can find your postgresql bin path…. and register it on PATH

$ export PATH=/{usr/local/pgsql}/bin:$PATH enter your own postgresql path in the braceses{}

and install $ pip install -U psycopg2 (or easy_install psycopg2 or python setup.py install)

파이썬 기본버전이 아닌경우 경로를 명시해서 실행해주면 된다.

ex) /opt/bin/python, /opt/bin/easy_install

 

[root@localhost libs_dependencies]# 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.5.1 Downloading http://initd.org/psycopg/tarballs/PSYCOPG-2-5/psycopg2-2.5.1.tar.gz Processing psycopg2-2.5.1.tar.gz Running psycopg2-2.5.1/setup.py -q bdist_egg –dist-dir /tmp/easy_install-F6sQUn/psycopg2-2.5.1/egg-dist-tmp-k_7mrO In file included from psycopg/psycopgmodule.c:27: ./psycopg/psycopg.h:30:20: error: Python.h: 그런 파일이나 디렉터리가 없습니다 ./psycopg/psycopg.h:31:22: error: libpq-fe.h: 그런 파일이나 디렉터리가 없습니다 In file included from ./psycopg/psycopg.h:34, from psycopg/psycopgmodule.c:27: ./psycopg/python.h:29:26: error: structmember.h: 그런 파일이나 디렉터리가 없습니다 ./psycopg/python.h:31:26: error: stringobject.h: 그런 파일이나 디렉터리가 없습니다 ./psycopg/python.h:35:4: error: #error “psycopg requires Python >= 2.5” In file included from ./psycopg/psycopg.h:34, from psycopg/psycopgmodule.c:27: ./psycopg/python.h:131: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token In file included from psycopg/psycopgmodule.c:27: ./psycopg/psycopg.h:59: error: expected ‘)’ before ‘*’ token ./psycopg/psycopg.h:60: error: expected ‘)’ before ‘*’ token ./psycopg/psycopg.h:63: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token ./psycopg/psycopg.h:67: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token

yum install python-devel postgresql-devel

sudo apt-get install libpq-dev

c헤더가 필요하데