xml-parsing with sax and 2.42a problem

I get this error:

xml.sax._exceptions.SAXReaderNotAvailable

with this import code:

from xml.sax import make_parser
parser = make_parser()

But with my own cvs-build it works. I have full Python 2.4 (Linux). Could some one clarify this, please!

I’m very confused :confused:

Sometimes your Python and the Python Blender was built for is not exactly compatible. For instance, when I do a simple “import random” in 2.42a from Blender Foundation, I get:

Traceback (most recent call last):
  File "Text", line 5, in ?
  File "/usr/lib/python2.4/random.py", line 44, in ?
    from math import log as _log, exp as _exp, pi as _pi, e as _e
ImportError: /usr/lib/python2.4/lib-dynload/math.so: cannot open shared object file: No such file or directory

although both Python versions (Blender and mine) are 2.4, and /usr/lib/python2.4/lib-dynload/math.so is present. When I do the same in my self compiled Blender 2.42a, all is well.

If I try your code, it works in both Blender versions for me, though. This is on Ubuntu 6.06 LTS (Dapper) with Python 2.4.3.

Thanks, maybe that explains it. And I forgot the second line of code :o

 from xml.sax import make_parser
parser = make_parser()

With your complete code I get an error in my Blender Foundation build:

Traceback (most recent call last):
  File "Text", line 2, in ?
  File "/usr/lib/python2.4/site-packages/_xmlplus/sax/sax2exts.py", line 37, in make_parser
    return XMLParserFactory.make_parser(parser_list)
  File "/usr/lib/python2.4/site-packages/_xmlplus/sax/saxexts.py", line 75, in make_parser
    sys.modules[parser_name].create_parser = _create_parser
KeyError: 'xml.sax.drivers2.drv_pyexpat'

With my self compiled Blender it works, which supports my theory. :slight_smile: