Ubuntu

[oneiric] ImportError: can't import mx.DateTime module

Reported by Marc Tardif on 2011-07-15
78
This bug affects 5 people
Affects Status Importance Assigned to Milestone
psycopg2 (Ubuntu)
High
Unassigned
Oneiric
High
Unassigned

Bug Description

I'm running Oneiric with the latest updates as of today. This is a fresh install from the desktop image of today and I just installed python-psycopg2. Then, this is what I get when I try to import the module:

$ python
Python 2.7.2+ (default, Jul 10 2011, 09:48:58)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 69, in <module>
    from _psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: can't import mx.DateTime module

For your information, python-egenix-mxdatetime where mx.DateTime resides is indeed installed. So, since psycopg2 is importing _psycopg which is a shared object file, I suspect this might be a multi-arch problem.

Prevents the package from being used, so should be High importance.

---
Ubuntu Bug Squad volunteer triager
http://wiki.ubuntu.com/BugSquad

Changed in psycopg2 (Ubuntu):
status: New → Confirmed
importance: Undecided → High
Marc Tardif (cr3) wrote :

By the way, branching the downstream project from lp:ubuntu/psycopg2, building it with debuild and then installing the resulting deb file produces a working package, eg no ImportError exception is raised but not sure whether that's because HAVE_MXDATETIME was not defined during compilation. I will try in an sbuild environment later.

Marc Tardif (cr3) wrote :

So, I tried rebuilding psycopg2 in an sbuild environment and installing the package has the same outcome as when I rebuilt with debuild, eg no ImportError exception is raised. Might it be possible that the oneiric package building environment has changed since the python-psycopg2 package was last built, so maybe just rebuilding it might solve the problem?

Hello, I am one of the current psycopg maintainers.

This problem was addressed in release 2.4.2. In previous releases, if the mx include files were found (by setup.py) the mx support was compiled and mx.DateTime was unconditionally imported at psycopg2 import time. This creates the error reported here (and in http://psycopg.lighthouseapp.com/projects/62710/tickets/53) if the module is not actually available. The error has been reported only recently (probably trigger by the use of virtualenv with "pure environments").

The issue was fixed in psycopg 2.4.2, where the import is no more unconditional even if the mx support is built at compile time. I suggest to upgrade the package to the most recent version.

Barry Warsaw (barry) wrote :

2.4.2 is in Debian, but autosyncs have been disabled because we've got Ubuntu-specific differences. They look superficial though:

psycopg2 (2.2.1-1ubuntu2) natty; urgency=low

  * Rebuild to add support for python 2.7.

 -- Matthias Klose <email address hidden> Fri, 03 Dec 2010 00:07:07 +0000

psycopg2 (2.2.1-1ubuntu1) maverick; urgency=low

  * Merge from Debian (LP: #611040). Remaining changes:
    debian/control, debian/rules: Install a seperate testsuite package.

 -- Mikhail Turov <email address hidden> Wed, 28 Jul 2010 21:20:45 +0100

Certainly the first change is unimportant, and I'll take a closer look to see why we need to carry the second one. If we don't then a sync to Debian's latest should do the trick.

Barry Warsaw (barry) wrote :

...and we'd get a conversion to dh_python2 for free! :)

Barry Warsaw (barry) wrote :

See bug 811193 for the sync request.

Stefano Rivera (stefanor) wrote :

That's not the only thing going on here. I notice that if I just rebuild psycopg2, it works again.

It looks like mxDateTime checks API version in its import function (mxDateTime_ImportModuleAndAPI). We used a new upstream mxDateTime which switched to "API2", and so the import failed in psycopg.

The sync will fix it.

Barry Warsaw (barry) wrote :

Thanks for looking at this in more detail Stefano. I've re-pinged the archive admins on the psycopg2 sync. I think we've waited long enough for a response on the Ubuntu delta. My opinion is that we don't need it, and we should just do the sync.

Changed in psycopg2 (Ubuntu):
status: Confirmed → Triaged
Barry Warsaw (barry) wrote :

The sync request in bug 811193 was fixed released, so that should fix this problem too.

Changed in psycopg2 (Ubuntu Oneiric):
milestone: none → oneiric-alpha-3
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers