Effbot's SimpleXMLWriter fails when py2exe'd

E

Erik Bethke

Hello All,

So I have been using Effbot's XML stuff a lot! And I have been using
py2exe, pygame and wxPython all mixed together...

I am getting this strange error log when writing XML files with his XML
writer. It appears to be fouling up on the encoding, ONLY in the exe
version. Runs fine and great as a python script.

What this does is leave the file hanging open...

I could write out the XML myself, but I would rather use his class...
any ideas why it broke?

Thank you,
-Erik

code snippet:
def SaveVocabTree( self ):
ElementTree( self.vocabXMLTree ).write(self.currentPath,
encoding='utf-8')

error log:
Traceback (most recent call last):
File "vocab.py", line 457, in OnAdd
File "vocab.py", line 483, in AddWord
File "vocab.py", line 494, in SaveVocabTree
File "elementtree\ElementTree.pyc", line 666, in write
File "elementtree\ElementTree.pyc", line 684, in _write
File "elementtree\ElementTree.pyc", line 754, in _encode
LookupError: unknown encoding: utf-8
 
F

Fredrik Lundh

Erik said:
So I have been using Effbot's XML stuff a lot! And I have been using
py2exe, pygame and wxPython all mixed together...

I am getting this strange error log when writing XML files with his XML
writer. It appears to be fouling up on the encoding, ONLY in the exe
version. Runs fine and great as a python script.

you need to explicitly tell py2exe to include the relevant encodings
(from the encodings package in the standard library). adding a simple

import encodings.utf_8

to your script might help. if not, see the following wiki page:

http://starship.python.net/crew/theller/moin.cgi/EncodingsAgain

</F>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top