Mac + virtualenv + pip + postgresql =错误:找不到pg_config可执行文件 [英] Mac + virtualenv + pip + postgresql = Error: pg_config executable not found
问题描述
我正在尝试为教程安装postgres,但是pip
给我错误:
I was trying to install postgres for a tutorial, but pip
gives me error:
pip install psycopg
我得到的一小段错误:
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'.
virtualenv中的pg_config
在哪里?如何配置呢?我使用virtualenv是因为我不想在系统范围内安装postgres.
Where is pg_config
in my virtualenv? How to configure it? I'm using virtualenv because I do not want a system-wide installation of postgres.
推荐答案
在Mac上,如果您使用的是 Postgres.app ,pg_config文件位于您的/Applications/Postgres.app/Contents/Versions/<current_version>/bin
目录中.需要将其添加到您的系统路径中,以解决此错误,例如:
On the Mac, if you're using Postgres.app, the pg_config file is in your /Applications/Postgres.app/Contents/Versions/<current_version>/bin
directory. That'll need to be added to your system path to fix this error, like this:
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/<current_version>/bin
例如,如果当前Postgres.app版本为9.5,则此导出行将为:
So for example, if the current Postgres.app version is 9.5, this export line would be:
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.5/bin
使用Postgres.app的最新版本(> 9.5吗?),您可以简单地添加"latest"代替版本号,就像这样:
With more recent versions of the Postgres.app (> 9.5?), you can simply add "latest" in place of the version number, like so:
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin
这篇关于Mac + virtualenv + pip + postgresql =错误:找不到pg_config可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!