not sure how to interpret and solve ImportError from lxml using py2exe

51 Views Asked by At

I'm trying to build a standalone executable file from a python script using py2exe

The creation of the .exe file does not output any warning nor errors, but when i actually try to execute it from command prompt it outputs the following error:

Traceback (most recent call last):

File "", line 259, in load_module

File "", line 15, in

File "", line 13, in __load

ImportError: (cannot import name _elementpath) 'C:\CAD\Workspace\username\dev-env\dist\lxml.etree.pyd'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "", line 259, in load_module

File "", line 15, in

File "", line 11, in __load ...

File "", line 627, in _load_backward_compatible File "", line 261, in load_module

KeyError: 'lxml.objectify'

The call i use, in the div folder, is the following mdf2mat.exe C:\CAD\username\usefulScripts\dev-folder\dosingFromCANape.mdf

And this is the code of the script:

import mdfreader
import sys

fileIn = sys.argv[1]
mdfFile = mdfreader.Mdf(fileIn)
mdfFile.export_to_matlab()

and lastly, this is the code i use to create the .exe:

py2exe.freeze(console={"C:\CAD\Workspace\username\dev-env\mdf2mat.py"})

Now from the list of packages supported by py2exe, lxml has this remark:

if missing _elementhpath, either pull whole lxml library in packages=..., or put "from lxml import _elementhpath as _dummy" somewhere in code; in both cases also pull gzip in packages=...

which describes exactly my situation.

Since i'm quite the beginner with this i have no idea what it means with 'pulling whole library in packages' or 'pull gzip in packages' hence i cannot solve the issue.

0

There are 0 best solutions below