Py2exe lxml woes

后端 未结 2 1772
逝去的感伤
逝去的感伤 2020-12-08 07:42

I have a wxpython application that depends on lxml and works well when running it through the python interpreter. However, when creating an exe with py2exe, I got this error

2条回答
  •  隐瞒了意图╮
    2020-12-08 08:04

    Py2exe allows you to specify additional packages/modules to include with the options argument to setup(), in case they are not automatically detected. The following should work:

    from distutils.core import setup
    import py2exe
    
    setup(
        windows=[{'script': 'gui.py'}],
        options={
            'py2exe': 
            {
                'includes': ['lxml.etree', 'lxml._elementpath', 'gzip'],
            }
        }
    )
    

    I've also recently discovered PyInstaller, which has built-in support for a number of well-known packages, including lxml, so that might be worth a try as well.

提交回复
热议问题