为Anaconda Python安装psycopg2 [英] Install psycopg2 for Anaconda Python
问题描述
我有Anaconda Python 3.4,但是每当我运行旧代码时,我都会通过键入"source activate python2"切换到Anaconda Python 2.7.我的问题是我为Anaconda Python 3.4安装了psycopg2,但没有为Anaconda Python 2.7安装.当我在Python 2.7上运行pip install psycopg2时,出现以下消息:
I have Anaconda Python 3.4, however whenever I run older code I switch to Anaconda Python 2.7 by typing "source activate python2". My issue is that I have psycopg2 installed for Anaconda Python 3.4, but not for Anaconda Python 2.7. When I run pip install psycopg2 (on Python 2.7) I get the following message:
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'.
我刚开始编程,需要以下方面的帮助:
I am fairly new to programming and need help in:
1. Obtaining directory containing pg_config
2. Finding the path to Anaconda Python 2.7
3. Adding pg_config to the PATH.
完成这些步骤后,我应该可以进行pip install Install psycopg2
After I complete these steps I should be able to pip install Install psycopg2
推荐答案
您需要PostgreSQL的开发系统软件包,其中包含编译psycopg2扩展所需的头文件.对于我的CentOS 64位,要安装的命令是:
You need development system package for PostgreSQL which contains header files required to compile psycopg2 extension. For my CentOS 64 bit the command to install is:
yum install postgresql-devel.x86_64
但这取决于操作系统-对于Ubuntu,将是 apt-get install ...
-软件包名称在发行版之间略有不同.
完成此步骤后,步骤2和3应该就不需要了.
but it depends on the OS - for Ubuntu that would be apt-get install ...
- the name of the package varies slightly between distros.
Steps 2 and 3 should be unnecessary after you do this.
对于Mac OS来说,就是这样:
For Mac OS that would be just:
brew install postgresql
这篇关于为Anaconda Python安装psycopg2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!