How do I debug a non-functioning PyInstaller build?

后端 未结 2 1320
逝去的感伤
逝去的感伤 2020-12-10 13:57

I have used PyInstaller only once before, and it worked pretty straight forward with wxPython. I\'m currently trying to build a different project though. The project works w

2条回答
  •  爱一瞬间的悲伤
    2020-12-10 14:28

    Pyinstaller sometimes needs explicit references in the .spec file to correctly package dependencies.

    For more information, see ensuring proper import statements so that pyinstaller recognizes them.

    For instance, it is very easy to miss crucial dependencies if they are imported from outside one of your Python modules (e.g. from a jar or c++ file which pyinstaller will not read).

    dependency walker could be your first line of defense to systematically tracking missing DLLs. Simply download it and then load your exe or affiliated dlls to see which ones are missing dependencies. Then, it is just a wild goose chase tracking them down and manually adding them to your directory along with the .exe (assuming your packaging in one directory).

    As a side note, for pyinstaller 2.1 (python 2.7.6), I modified the pyi_importers.py file to at least try and print which module was the trouble maker when importing:

    # line 409 of Pyinstaller.loader.pyi_importers.py
    try: module = imp.load_module(fullname, fp, filename, self._c_ext_tuple)
    except Exception as e:
        print fullname # at least tells you what module couldn't be imported
        raise e
    

    Then, knowing where the issue occurred, you can then pin point the problem with dependency walker to root out the missing DLLs.

提交回复
热议问题