cx-freeze fails to include modules even when included specifically

后端 未结 2 1910
名媛妹妹
名媛妹妹 2020-12-19 10:24

I am trying to use cx-freeze to create a static self-contained distribution of my app (The Spye Python Engine, www.spye.dk), however, when I run cx-freeze, it says:

相关标签:
2条回答
  • 2020-12-19 10:36

    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.

    0 讨论(0)
  • 2020-12-19 10:43

    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).

    0 讨论(0)
提交回复
热议问题