"No module named cElementTree" in TGWebServices

28 views
Skip to first unread message

vit...@gmail.com

unread,
May 23, 2007, 12:21:08 PM5/23/07
to TurboGears
Hello all,

I'm starting to play around with TGWebServices. I just installed
TGWebServices 1.1.2, TG 1.0.2.2 on the latest Ubuntu 7.04 with python
2.5. So far so good, but I can't even import anything from the
interpreter, as in:

$ python
Python 2.5.1c1 (release25-maint, Apr 12 2007, 21:00:25)
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from tgwebservices.controllers import WebServicesRoot, WebServicesController, wsexpose, wsvalidate
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/site-packages/TGWebServices-1.1.2-py2.5.egg/
tgwebservices/controllers.py", line 14, in <module>
import cElementTree as et
ImportError: No module named cElementTree


What does this message mean? Any idea? Any help would be appreciated.
Thanks a lot in advance.

Regards,

--
Víctor Peinado

Florent Aide

unread,
May 23, 2007, 6:54:25 PM5/23/07
to turbo...@googlegroups.com
Le mercredi 23 mai 2007 à 16:21 +0000, vit...@gmail.com a écrit :
> Hello all,

[...]


> tgwebservices/controllers.py", line 14, in <module>
> import cElementTree as et
> ImportError: No module named cElementTree
>
>
> What does this message mean? Any idea? Any help would be appreciated.
> Thanks a lot in advance.

I was written with python 2.4 in mind. Either install cElementTree
manually or propose a patch to do this:

at line 14 in tgwebservices/controllers.py

instead of

import cElementTree as et

do:

try:
# python 2.5 way of life :)
import xml.etree.cElementTree as et
except:
# python 2.4
import cElementTree as et

you may have to do this in some other modules also. This comes from the
fact that elementtree was integrated in the standard python library
under the new xml.etree namespace.

Cheers,
Florent.

vit...@gmail.com

unread,
May 24, 2007, 9:20:19 AM5/24/07
to TurboGears
Hi Florent,

> I was written with python 2.4 in mind. Either install cElementTree
> manually or propose a patch to do this:
>
> at line 14 in tgwebservices/controllers.py
>
> instead of
>
> import cElementTree as et
>
> do:
>
> try:
> # python 2.5 way of life :)
> import xml.etree.cElementTree as et
> except:
> # python 2.4
> import cElementTree as et
>
> you may have to do this in some other modules also. This comes from the
> fact that elementtree was integrated in the standard python library
> under the new xml.etree namespace.

I've already replaced "import cElementTree as et" by "import
xml.etree.cElementTree as et" at tgwebservices/controllers.py and
tgwebservices/soap.py. Now I get this error when importing anything
from tgwebservices:

>>> from tgwebservices.controllers import WebServicesRoot


Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/site-packages/TGWebServices-1.1.2-py2.5.egg/

tgwebservices/controllers.py", line 14, in <module>

import xml.etree.cElementTree as et
ImportError: No module named etree.cElementTree

However, if I try to import cElementTree from the interpreter, it
works:

>>> import xml.etree.cElementTree as et
>>> dir(et)
['Comment', 'Element', 'ElementPath', 'ElementTree', 'PI',
'ProcessingInstruction', 'QName', 'SubElement', 'TreeBuilder',
'VERSION', 'XML', 'XMLID', 'XMLParser', 'XMLParserError',
'XMLTreeBuilder', '__builtins__', '__doc__', '__file__', '__name__',
'dump', 'fromstring', 'iselement', 'iterparse', 'parse', 'tostring']

Any idea? Should I report it for a patch to be added?

Best,

--
Víctor Peinado

Florent Aide

unread,
May 25, 2007, 5:49:59 PM5/25/07
to turbo...@googlegroups.com
Le jeudi 24 mai 2007 à 13:20 +0000, vit...@gmail.com a écrit :

> tgwebservices/controllers.py", line 14, in <module>
> import xml.etree.cElementTree as et
> ImportError: No module named etree.cElementTree
>
> However, if I try to import cElementTree from the interpreter, it
> works:
>
> >>> import xml.etree.cElementTree as et
> >>> dir(et)
> ['Comment', 'Element', 'ElementPath', 'ElementTree', 'PI',
> 'ProcessingInstruction', 'QName', 'SubElement', 'TreeBuilder',
> 'VERSION', 'XML', 'XMLID', 'XMLParser', 'XMLParserError',
> 'XMLTreeBuilder', '__builtins__', '__doc__', '__file__', '__name__',
> 'dump', 'fromstring', 'iselement', 'iterparse', 'parse', 'tostring']
>
> Any idea? Should I report it for a patch to be added?
>

yes : the easyest way for you is: easy_install cElementTree

it works I just tested it and with cElementTree installed I can import
everything from TGWS.

Cheers,

Florent.

vit...@gmail.com

unread,
May 26, 2007, 6:58:03 AM5/26/07
to TurboGears
Hello,

> > Any idea? Should I report it for a patch to be added?
>
> yes : the easyest way for you is: easy_install cElementTree
>
> it works I just tested it and with cElementTree installed I can import
> everything from TGWS.

You're right, it works! Thanks a lot! :-)

--
Víctor Peinado

Reply all
Reply to author
Forward
0 new messages