I am having trouble parsing xml files using ElementTree after the python code is turned into .exe using cx_freeze.
from xml.etree import ElementTree
file1 = 'file1'
file2 = 'file2'
tree1 = ElementTree.parse(file1)
tree2 = ElementTree.parse(file2)
print 'Done'
It works fine with the .py file, but after I made an .exe using cx_freeze, it would give the error:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27, in <module>
exec code in m.__dict__
File "test1.py", line 6, in <module>
tree1 = ElementTree.parse(file1)
File "C:\Python27\lib\xml\etree\ElementTree.py", line 1177, in parse
tree.parse(source, parser)
File "C:\Python27\lib\xml\etree\ElementTree.py", line 648, in parse
parser = XMLParser(target=TreeBuilder())
File "C:\Python27\lib\xml\etree\ElementTree.py", line 1447, in __init__
"No module named expat; use SimpleXMLTreeBuilder instead"
ImportError: No module named expat; use SimpleXMLTreeBuilder instead
I am using Python 2.7.2.5 and cx_freeze-4.2.win32-py2.7. The same issues happens for Python 2.6 as well.
Any suggestions would be appreciated.
Thanks!