How can I make a Python script standalone executable to run without ANY dependency?

后端 未结 19 2763
眼角桃花
眼角桃花 2020-11-21 04:51

I\'m building a Python application and don\'t want to force my clients to install Python and modules.

So, is there a way to compile a Python script to be a standalone

19条回答
  •  无人及你
    2020-11-21 05:46

    pyinstaller yourfile.py -F --onefile
    

    This creates a standalone EXE file on Windows.

    Important note 1: The EXE file will be generated in a folder named 'dist'.

    Important note 2: Do not forget --onefile flag

    You can install PyInstaller using pip install PyInstaller

    NOTE: In rare cases there are hidden dependencies...so if you run the EXE file and get missing library error (win32timezone in the example below) then use something like this:

    pyinstaller --hiddenimport win32timezone -F "Backup Program.py"
    

提交回复
热议问题