我有 Anaconda Python 3.4,但是每当我运行旧代码时,我都会通过键入“source activate python2”切换到 Anaconda Python 2.7。我的问题是我为 Anaconda Python 3.4 安装了 psycopg2,但没有为 Anaconda Python 2.7 安装。当我运行 pip install psycopg2(在 Python 2.7 上)时,我收到以下消息:
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'.
我对编程还很陌生,需要以下方面的帮助:
1. Obtaining directory containing pg_config
2. Finding the path to Anaconda Python 2.7
3. Adding pg_config to the PATH.
完成这些步骤后,我应该能够 pip install 安装 psycopg2
原文由 user3062459 发布,翻译遵循 CC BY-SA 4.0 许可协议
您需要 PostgreSQL 的开发系统包,其中包含编译 psycopg2 扩展所需的头文件。对于我的 CentOS 64 位,安装命令是:
但这取决于操作系统 - 对于 Ubuntu 来说是
apt-get install ...
- 软件包的名称在发行版之间略有不同。执行此操作后,第 2 步和第 3 步应该是不必要的。
编辑: 对于 Mac OS 那只是:
如 这里 所写