Compile Python 3.6 script to standalone exe with Nuitka on Windows 10

前端 未结 2 595
攒了一身酷
攒了一身酷 2021-02-06 00:24

Note:
Before marking this question as duplicate, please verify that the other question answers the topic for this setup:

  • OS: Windows 10, 64-bit
相关标签:
2条回答
  • 2021-02-06 00:50

    Easier than Nuitka for a single executable is e.g. PyInstaller: pyinstaller --onefile program.py (to disable the console window for GUI applications add the -w option).

    To create a single executable with Nuitka, you can create a SFX archive from the generated files. You can run Nuitka with the --standalone option which generates a program_dist directory.

    Create then a 7-Zip SFX config file config.txt: ;!@Install@!UTF-8! GUIMode="2" ExecuteFile="%%T/program_dist/program.exe" ;!@InstallEnd@!

    Then get the 7-Zip SFX from https://github.com/chrislake/7zsfxmm (from releases – 7zsd_extra_171_3901.7z) and unpack the 7zsd_All_x64.sfx file.

    Pack then the program_dist with 7-Zip (so the folder is included in the archive) to program.7z. Then, an SFX can be created with copy /b 7zsd_All_x64.sfx + config.txt + program.7z single_executable.exe.

    On Unix, you can also create yourself an SFX if you create a tar archive and append it to a shell script which extract it and unpack it, for details see https://www.linuxjournal.com/node/1005818.

    0 讨论(0)
  • 2021-02-06 01:15

    Open console and type:

    nuitka --recurse-all program.py
    

    An exe file will be created. Run it.

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