找不到pg_config可执行文件

2024-04-25 21:10:14 发布

您现在位置:Python中文网/ 问答频道 /正文

安装psycopg2时遇到问题。当我试图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

但问题是pg_config实际上在我的PATH中;它运行时没有任何问题:

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

我尝试将pg_配置路径添加到setup.cfg文件中,并使用从他们的网站(http://initd.org/psycopg/)下载的源文件构建它,得到以下错误消息!

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

但它确实在那里!!!

我对这些错误感到困惑。有人能帮忙吗?

顺便说一下,我sudo所有的命令。我也在5.5区。


Tags: piporthetopathinbuildconfig
3条回答

你安装了python-dev吗? 如果已经安装了,请尝试同时安装libpq-dev

sudo apt-get install libpq-dev python-dev

来自文章:How to install psycopg2 under virtualenv

在Mac OS X上,我使用homebrew包管理器解决了这个问题

brew install postgresql

pg_config位于postgresql-devellibpq-dev位于Debian/Ubuntu中,libpq-devel位于Cygwin/Babun中。)

相关问题 更多 >