2015-11-05 57 views
0

我有一个的virtualenv venv在那里我有点子安装mx-basepsycopg2如何使用mx支持在virtualenv中安装psycopg2?

$ 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' 

或者:

[email protected]:~(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 - 支持。

我该如何解决这个问题?

回答

1

您可能需要自行构建psycopg2,下载tar.gz,解压缩,然后找到setup.cfg文件,将mx_include参数修改为/lib/python2.7/site-packages/mx/DateTime/mxDateTime然后

python setup.py build_ext install