PyInstaller not working on simple HelloWorld Program

后端 未结 2 528
暗喜
暗喜 2020-12-13 04:45

So I am running on 64-bit Windows 7, and I set up Pyinstaller with Pip and PyWin32. I have python 2.7.

I made a simple hello world Program with this code

<         


        
相关标签:
2条回答
  • 2020-12-13 05:03

    Thanks @tul! My version of pyinstaller put it to dist\helloworld.exe though!

    If you start it from C:\Python27\Scripts... that'll be C:\Python27\Scripts\dist... as well!

    But whereever you have it, I recommend putting a batch file next to your .py to be able recompile any time with just a click:

    I set it up so there is nothing but the .exe at the .py location and the temporary stuff goes to the temp dir:

    @echo off
    :: get name from filename without path and ext
    set name=%~n0
    echo ========= %name% =========
    
    :: cut away the suffix "_build"
    set name=%name:~0,-6%
    set pypath=C:\Python27\Scripts
    set buildpath=%temp%
    
    if not exist %name%.py (
        echo ERROR: "%name%.py" does not exist here!
        pause
        exit /b
    )
    
    %pypath%\pyinstaller.exe --onefile -y %~dp0%name%.py --distpath=%~dp0 --workpath=%buildpath% --specpath=%buildpath%
    

    I name it like the .py file plus "_build" and cut away the suffix in the batch script again. Voilà.

    0 讨论(0)
  • 2020-12-13 05:09

    Run with the -F flag to produce the standalone exe:

    pyinstaller -F helloworld.py
    

    It will output to dist/helloworld.exe

    NOTE this is a different location to when -F is not used, be sure to run the right exe afterwards.

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