import statement not updated for Python 2.5 (needs: from xml.etree import cElementTree)

Bug #138349 reported by lcampagn on 2007-09-08
22
Affects Status Importance Assigned to Milestone
elementtree (Ubuntu)
Undecided
Unassigned
python-gdata (Ubuntu)
Low
Unassigned

Bug Description

Binary package hint: python-elementtree

The gdata module (in python-gdata) is trying to import elementtree improperly and should be fixed.

lcampagn (luke-campagnola) wrote :

Quick update: I was incorrect when I thought moving these files would fix the problem. here is the actual error I'm having:

>>> import gdata
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/var/lib/python-support/python2.5/gdata.py", line 29, in <module>
    from elementtree import ElementTree
ImportError: No module named elementtree

I'm not certain whether the problem is in gdata or elementtree.

Brad Crittenden (bac) wrote :

On a system updated from feisty to gutsy I am having the same problem. python2.5 cannot import elementtree but python2.4 can.

Basilio Kublik (sourcercito) wrote :

I believe that in python 2.5 you must import elementtree as xml.etree.ElementTree, look at http://effbot.org/zone/element-index.htm#installation.
if that's the case, i think this could be a bug in python-gdata which must include a clause for python >= 2.5.

Changed in python-elementtree:
importance: Undecided → Low
status: New → Incomplete
Basilio Kublik (sourcercito) wrote :

Here I attach a patch for python-gdata-1.0 package, including the clause i comment above, please try it and confirm if it works.
I'm not a python programmer so could not be the best workaround ever, but here does the job.

Basilio Kublik (sourcercito) wrote :

actually there's a slightly better way than the provided by the previous patch, please take a look to this one instead.

Davim (davim) wrote :

I confirm this bug in Ubuntu Gutsy final release.

don hardaway (don-hardaway) wrote :

Basilio ---Please tell me what to do with the file you listed above?

Basilio Kublik (sourcercito) wrote :

same as previous patch, but this time in debdiff format.

Don, take a look at https://wiki.ubuntu.com/MOTU/School/PatchingSources for information about how to patch code, if you have questions about it please feel free to raise your question at the support tracker https://answers.launchpad.net/

don hardaway (don-hardaway) wrote :

Thanks Basilio but that documentation on patching made no sense to me. I simply need the stepwise instruction of what to do with the file you attached to get the gdata to work right.

don hardaway (don-hardaway) wrote :

Could someone please tell be how to apply Basilio's debdiff patch so I can get my program to work?

dirken (dirkvranckaert) wrote :

The problem is that all files in directory /var/lib/python-support/python2.5/ should be changed, the imports used in those files (such as gdata.py and atom.py) are:
from elementtree import ElementTree

and this should be changed in every file to:
try:
  from xml.etree import cElementTree # for Python 2.5 users
except ImportError:
  from elementtree import cElementTree

As long as this isn't updated elementree won't work with python 2.5
The patching solution seems to complicated to me so isn't there any other solution?
Or maybe anyone who wants to change all the files? :p

Passeli (passeli) wrote :

I have similar problem, but with different application (eTiny ). I get following error message when trying to start it:

passeli@godzilla:/usr/lib/python2.5/site-packages/eTiny-1.0rc1-py2.5.egg/EGG-INFO/scripts$ start-tinyerp.py
Traceback (most recent call last):
  File "/usr/bin/start-tinyerp.py", line 4, in <module>
    import pkg_resources
  File "/usr/lib/python2.5/site-packages/setuptools-0.6c7-py2.5.egg/pkg_resources.py", line 2561, in <module>
  File "/usr/lib/python2.5/site-packages/setuptools-0.6c7-py2.5.egg/pkg_resources.py", line 626, in require
  File "/usr/lib/python2.5/site-packages/setuptools-0.6c7-py2.5.egg/pkg_resources.py", line 524, in resolve
pkg_resources.DistributionNotFound: elementtree>=1.2.6

Does this mean that in the setuptools-0.6c7 has same problem with elementtree?

misan (misan) wrote :

There seems to be more trouble that elementtree as other imports on gcalcli do give errors after changing the elementtree thing

Traceback (most recent call last):
  File "./gcalcli", line 59, in <module>
    from gdata.calendar.service import *
ImportError: No module named calendar.service

misan (misan) wrote :

I reckon several people complained about the same thing, it seems the version change on Python to 2.5 may have created the problems reported

Changed in python-gdata:
status: Incomplete → Confirmed
Jens Jorgensen (jorgensen) wrote :

Please note that although the problem in python-gdata can be fixed by importing elementtree via xml.etree there is still another problem.

Python 2.5 includes elementtree inside the python base distribution however it only includes a _subset_ of elementtree. This is why the python-elementtree is still available and needed as an extension module in Python 2.5. What's needed is to change

/usr/share/python-support/python-elementtree/.version

from 2.3-2.4 to 2.3-2.5 or whatever else might be appropriate.

Adrian Petrescu (apetresc) wrote :

This bug shouldn't have priority 'low'. It renders the package completely unusable for anyone with Python 2.5, and a patch already exists. I think this bug should be fixed (by applying Basilio's patch) and backported to Gutsy asap.

Sebastien Bacher (seb128) wrote :

the import works correctly on hardy, is that still an issue there?

Pchunt (pchunt-gmail) wrote :

Using Hardy (python2.5) running a WSGI app which depends on python-elementtree via Apache2 I get the following in /var/log/apache2/error.log:

 File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 524, in resolve, referer: http://192.168.111.134/dashboard/index.wsgi/page/sidebar
 raise DistributionNotFound(req) # XXX put more info here, referer: http://192.168.111.134/dashboard/index.wsgi/page/sidebar
 DistributionNotFound: elementtree>=1.2,<=1.3, referer: http://192.168.111.134/dashboard/index.wsgi/page/sidebar
 mod_wsgi (pid=13362): Target WSGI script '/usr/lib/webui/index.wsgi' cannot be loaded as Python module.

As a work around I create a symlink in /var/lib/python-support/python2.5/ to /usr/share/python-support/python-elementtree/elementtree-1.2.6_20050316.egg-info as this seems to be what some other packages do (eg python-decorator).

garyo (garyo) wrote :

Still a bug in hardy, I confirm it. On a stock install, do this:

% apt-get install python-gdata # install python GData API
% cd /tmp
% cp /usr/share/doc/python-gdata/samples/calendarExample.py.gz .
% gunzip calendarExample.py
% python calendarExample.py
Traceback (most recent call last):
  File "calendarExample.py", line 21, in <module>
    from elementtree import ElementTree
ImportError: No module named elementtree

Python 2.5 requires importing ElementTree like this:
  from xml.etree import ElementTree

... so the gdata python package should be updated to include the try clauses others have suggested above.

Allan Day (allanday) wrote :

I get the same thing on Hardy, 'from xml.etree import ElementTree' does work though: thanks garyo.

Daniel T Chen (crimsun) on 2008-11-19
Changed in python-elementtree:
status: New → Invalid
description: updated
Jonathan Davies (jpds) wrote :

This bug appears to have been fixed by upstream, however the version stated is only in Jaunty:

=== 1.0.13 ===
May 8, 2008 (revision 357)

...
- Fixed a bug in the gdata.apps.service module which caused an import to
    fail when loading ElementTree in some cases.
...

This has been resolved in Ubuntu for some time now, since Jaunty. I'm closing this as fixed released.

The only supported release that this remains an issue for is Hardy. If some one is interested in pursuing a Stable Release Update for this on Hardy, please see: https://wiki.ubuntu.com/StableReleaseUpdates#Procedure

Changed in python-gdata (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers