所以我现在已经使用psycopg2
了一段时间,但现在只是在运行我们的脚本时遇到了这个错误。
Traceback (most recent call last):
File "engine/LinkOracleEngine.py", line 8, in <module>
from util.DoSQL import DoSQL
File "/home/zero/Documents/Thesis/Source Code/engine/util/DoSQL.py", line 4, in <module>
import psycopg2
File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 50, in <module>
from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: No module named _psycopg
为什么?从我以前的用途来看,导入psycopg2
没有问题,但现在已经有了。我更新了它,似乎没有任何变化,我甚至通过psycopg2
安装了另一个pip3
,但它仍然是相同的。
我甚至尝试在python控制台中导入sys
,然后将它所在的库(/usr/lib/python2.7/dist-packages/psycopg2/
)附加到sys.path
,但仍然得到相同的ImportError: No module named _psycopg
>>> import sys
>>> sys.path.append('/usr/lib/python2.7/dist-packages/')
>>> import psycopg2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 50, in <module>
from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: No module named _psycopg
>>> sys.path
['', '/opt/anaconda2/lib/python27.zip', '/opt/anaconda2/lib/python2.7', '/opt/anaconda2/lib/python2.7/plat-linux2', '/opt/anaconda2/lib/python2.7/lib-tk', '/opt/anaconda2/lib/python2.7/lib-old', '/opt/anaconda2/lib/python2.7/lib-dynload', '/home/zero/.local/lib/python2.7/site-packages', '/opt/anaconda2/lib/python2.7/site-packages', '/opt/anaconda2/lib/python2.7/site-packages/Sphinx-1.3.1-py2.7.egg', '/opt/anaconda2/lib/python2.7/site-packages/cryptography-1.0.2-py2.7-linux-x86_64.egg', '/opt/anaconda2/lib/python2.7/site-packages/setuptools-18.5-py2.7.egg', '/usr/lib/python2.7/dist-packages/']
>>>
上次我记得在我的笔记本电脑和PC之间使用mpich
和mpich4py
设置了一个群集,但这似乎不会直接影响我的psycopg2
权利?如果我错了,请纠正我。