This project is archived and is in readonly mode.
mx erroneously detected inside virtualenv
Reported by Anders Pearson | April 27th, 2011 @ 04:16 PM
Briefly, the issue is that when installing psycopg2 in a
virtualenv that was created with
(in an attempt to be completely independent of the underlying
system), psycopg2's setup.py will still find mx and set
HAVE_MXDATETIME=1. The compilation and install
succeed, but since mx isn't installed in the virtualenv, importing
psycopg2 results in an
ImportError: can't import mx.DateTime
As far as I can tell, this happens because setup.py does
mxincludedir = os.path.join(get_python_inc(plat_specific=1), "mx")
to determine whether mx is available. That will find the mx
include directory (eg,
it will be able to compile. But this is circumventing the
virtualenv and isn't safe behavior when installing into a
I can easily set
mxincludedir to a bogus directory
to trick it into thinking mx isn't installed anywhere and get it to
work, but that doesn't strike me as the best and cleanest
I'm not sure exactly what the best solution is overall, but I'd suggest that one way or another, psycopg2 should only compile in mx.DateTime support when it can both find the mx headers and know that the mx python library will be available.
Comments and changes to this ticket
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<b>WARNING:</b> the informations in this tracker are archived. Please submit new tickets or comments to <a href="https://github.com/psycopg/psycopg2/issues">the new tracker</a>.
Psycopg is the most used PostgreSQL adapter for the Python programming language. At the core it fully implements the Python DB API 2.0 specifications. Several extensions allow access to many of the features offered by PostgreSQL.