pg_config executable not found

2019-01-04 04:22发布

I am having trouble installing psycopg2. I get the following error when I try to pip install 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'.

----------------------------------------
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build/psycopg2

But the problem is pg_config is actually in my PATH; it runs without any problem:

$ which pg_config
/usr/pgsql-9.1/bin/pg_config

I tried adding the pg_config path to the setup.cfg file and building it using the source files I downloaded from their website (http://initd.org/psycopg/) and I get the following error message!

Error: Unable to find 'pg_config' file in '/usr/pgsql-9.1/bin/'

But it is actually THERE!!!

I am baffled by these errors. Can anyone help please?

By the way, I sudo all the commands. Also I am on RHEL 5.5.

27条回答
放我归山
2楼-- · 2019-01-04 05:06

for CentOS/RedHat make sure that /etc/alternatives/pgsql-pg_config is a non-broken symlink

查看更多
爷、活的狠高调
3楼-- · 2019-01-04 05:08

On Mac OS X, I solved it using the homebrew package manager

brew install postgresql
查看更多
时光不老,我们不散
4楼-- · 2019-01-04 05:08

Also on OSX. Installed Postgress.app from http://postgresapp.com/ but had the same issue.

I found pg_config in that app's contents and added the dir to $PATH.

It was at /Applications/Postgres.app/Contents/Versions/latest/bin. So this worked: export PATH="/Applications/Postgres.app/Contents/Versions/latest/bin:$PATH".

查看更多
我欲成王,谁敢阻挡
5楼-- · 2019-01-04 05:08

sudo apt-get install libpq-dev works for me on Ubuntu 15.4

查看更多
狗以群分
6楼-- · 2019-01-04 05:11

pg_config is in postgresql-devel (libpq-dev in Debian/Ubuntu, libpq-devel on Cygwin/Babun.)

查看更多
Lonely孤独者°
7楼-- · 2019-01-04 05:11

UPDATE /etc/yum.repos.d/CentOS-Base.repo, [base] and [updates] sections
ADD exclude=postgresql*

curl -O http://yum.postgresql.org/9.1/redhat/rhel-6-i386/pgdg-centos91-9.1-4.noarch.rpmr  
rpm -ivh pgdg-centos91-9.1-4.noarch.rpm

yum install postgresql  
yum install postgresql-devel

PATH=$PATH:/usr/pgsql-9.1/bin/

pip install psycopg2
查看更多
登录 后发表回答