PyInstaller, spec file, ImportError: No module named 'blah'

前端 未结 3 1897
走了就别回头了
走了就别回头了 2020-12-01 09:43

I am trying to build a python script via PyInstaller. I have used the following commands to configure, generate a spec file, and build:

wget pyinstaller.zip         


        
3条回答
  •  没有蜡笔的小新
    2020-12-01 10:24

    just gonna add my 2 cents because I encountered the same problem today - 6 years later :D

    For Windows:

    1) cmd => rightclick => with admin rights
    2) Enter in cmd: "pip install pyinstaller"
    3) navigate in cmd to the folder of "yourMain.py"
    4) Enter in cmd: "pyinstaller --onefile --windowed yourMain.py"
    
    5) If you import other scripts / data in "yourMain.py": 
    Manually enter the folder "dist" (gets created - where "yourMain.exe" should be by now), 
    and copy your scripts or folder structure there
    
    (e.g. /assets/sounds; /assets/graphics; /scripts; anotherscript.py )
    

    Then I was able to run the exe by double clicking.

    Turned out to be pretty easy. What did the trick for me was the "--onfile" and adding my other files to the "dist" folder.

    The "--windowed" is just so the python command window won't pop up when you start the exe.

提交回复
热议问题