我有一个virtualenv venv
我在其中安装了mx-base
和psycopg2
与pip:
$ pip freeze | grep "psyco\|mx"
egenix-mx-base==3.2.8
psycopg2==2.6
psycopg2
的基础知识有效,但在使用扩展程序时,我会遇到以下异常:
Traceback (most recent call last):
File "/my_proj/my_code.py", line 32, in <module>
register_types()
File "/my_proj/my_code.py", line 28, in register_types
psycopg2.extensions.register_type(psycopg2._psycopg.MXDATETIME)
AttributeError: 'module' object has no attribute 'MXDATETIME'
或者:
ulf@kalla:~(0)(venv)$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
>>> #Use mx.DateTime instead of pythons datetime, for compability reasons.
... psycopg2.extensions.register_type(psycopg2._psycopg.MXDATETIME)
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
AttributeError: 'module' object has no attribute 'MXDATETIME'
>>>
似乎已安装的psycopg2
版本缺少mx
- 支持。
我该如何解决这个问题?
答案 0 :(得分:1)
您可能需要自己构建psycopg2,下载tar.gz,解压缩,然后找到setup.cfg文件,将mx_include参数修改为/lib/python2.7/site-packages/mx/ DateTime / mxDateTime然后
python setup.py build_ext install