天天看点

解决python-xml 模块 在ubuntu karmic中找不到的问题

如下错误:

 from xml.dom.ext.reader.Sax2 import FromXmlStream

ImportError: No module named ext.reader.Sax2

转自:

https://bugs.launchpad.net/ubuntu/+source/python-xml/+bug/343242

runo Harbulot wrote on 2009-11-29: #22

Going

back to Windows just because of this seems a bit radical. If PyXML is

what's required, doing the following seems rather straightforward

compared with some DLL conflicts:

1. Download PyXML-0.8.4.tar.gz from

http://sourceforge.net/projects/pyxml/files/

2. You may need to install python2.6-dev, for example via: sudo apt-get

install python2.6-dev

3. Use these commands:

tar xvzf PyXML-0.8.4.tar.gz

cd PyXML-0.8.4

wget

http://launchpadlibrarian.net/31786748/0001-Patch-for-Python-2.6.patch

patch -p1 < 0001-Patch-for-Python-2.6.patch

sudo python2.6 setup.py install

I still reckon PyXML should be packaged in its own package (if the

other things in python-xml are broken). I think the patch is easy

enough for it to be dealt with as part of the packaging process.

Libxml2 may be the modern way to do XPath in Python, but having all the

legacy applications (whether-or-not packaged by Debian/Ubuntu) that

currently rely on PyXML change their code to use libxml2 sounds like a

lot of work, possibly unrealistic.