如何为python 2.7安装psycopg2

时间:2018-01-08 02:58:18

标签: python-2.7 pip

虽然isntaling binaryanalysis我有一个错误ImportError:没有名为psycopg2的模块,但我已经安装了它,但它只能用于python 3.5。我如何为python2.7安装它?

Python 3.5

$ python3.5
Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
>>> exit
Use exit()

Python 2.7

$ python2.7
Python 2.7.12 (default, Nov 20 2017, 18:23:56) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named psycopg2
>>> 

编辑:

$ pip install psycopg2 
Requirement already satisfied: psycopg2 in /usr/local/lib/python3.5/dist-packages

1 个答案:

答案 0 :(得分:1)

尝试一下

pip install psycopg2-binary

我是针对Python 2.7执行此操作的,不确定是否适用于Python 3.6