我试图安装一个教程的postgres,但是pip
给了我一个错误:
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'.
pg_config
在我的虚拟环境中的什么位置?如何配置?我使用virtualenv是因为我不想在系统范围内安装postgres。
发布于 2014-06-14 14:38:42
在苹果电脑上,如果你使用的是Postgres.app,那么pg_config文件就在你的/Applications/Postgres.app/Contents/Versions/<current_version>/bin
目录中。需要将其添加到系统路径以修复此错误,如下所示:
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/<current_version>/bin
因此,例如,如果当前Postgres.app版本为9.5,则此导出行将为:
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.5/bin
对于更新版本的Postgres.app (> 9.5?),您可以简单地添加"latest“来代替版本号,如下所示:
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin
发布于 2014-03-14 13:18:16
在Mac上,解决方案是安装postgresql
brew install postgresql
在CentOS上,解决方案是安装postgresql-devel
sudo yum install postgresql-devel
pg_config
在postgresql-devel
包中
发布于 2014-11-02 08:31:54
我完全同意john hight的观点,即大多数发布的答案都是完全离题的,假设OP确切地指定了使用virtualenv的需求。
对我来说,答案是在激活virtualenv时在提示符下运行以下命令:
export PATH="/Applications/Postgres.app/Contents/Versions/9.4/bin:$PATH"
(请注意,第9.4部分代表版本,可能会有所不同)
或者,如果您想使用安装的最新版本的Postgres:
export PATH="/Applications/Postgres.app/Contents/Versions/latest/bin:$PATH"
然后:
pip install psycopg2
假设你已经安装了postgres,那就成功了。如果没有,那么请记住最好的和推荐的解决方案是使用:Postgres.app
https://stackoverflow.com/questions/20170895
复制相似问题