cx-freeze fails to include modules even when included specifically

对着背影说爱祢 提交于 2019-11-29 11:04:11

Missing modules aren't necessarily a problem: a lot of modules try different imports to accommodate different platforms or different versions of Python. In subprocess, for example, you can find this code:

if mswindows:
    ...
    import _subprocess

cx_Freeze doesn't know about this, so it will try to find _subprocess on Linux/Mac as well, and report it as missing. Specifying them in includes doesn't change anything, because it's trying to include them, but unable to find them.

It should build a file anyway, so try running that and seeing if it works.

I guess, you can not simply += on lists.

You should probably use the list method extend - otherwise the original list will not be modified:

includes.extend(["BaseHTTPServer", "<rest of your modules>"])

EDIT: (Thank @ThomasK)

+= works fine - I only had an online Python interpreter that did not work correctly. (I have no python install on my Windows installation so I had to check online).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!