Back
Featured image of post Python Nuitka Packaging Tutorial

Python Nuitka Packaging Tutorial

Python Nuitka packaging is a difficult thing, but it is not that difficult if you master the method

Table of contents

TL;DR / [Geek Summary]:

  • Reverse Engineering Shield: Move beyond PyInstaller’s transparent packaging; Nuitka compiles Python to C++ to fortify your source code.
  • Performance Leap: Leverage native machine code for faster execution, breaking the efficiency bottlenecks of pure interpretation.
  • Deployment Guardrails: Stick to stable Python 3.8.10, avoid non-ASCII paths, and use --onefile with zstandard for optimized binary distribution.

Python’s running speed and source code decompilation have always been a difficult problem. However, after using Nuitka, you will enjoy the speed of C++ and avoid the worry of being completely decompiled from the source code after being packaged by pyinstaller

# Explain the difference between pyinstaller and Nuitka

The difference between the two is that pyinstaller is cooking on the spot, and everything is clearly seen by the people present (unpacking the source code), but Nuitka is a bunch of things into a paste and you don’t know what is in it. You can only roughly guess what this thing does (disassembly can only get the assembly but not the source code)

# Python version selection

The older the Python version, the better, and the more compatible it is. Choosing python 3.8.10 is enough

# Notes

The installation directory cannot have Chinese, otherwise there will be a lot of bugs that you can’t solve

# PIP installs some things

1
2
3
pip install ordered-set # Accelerate compilation
pip install nuitka # Main program
pip install zstandard # Compress files when onefile

# One-click command

1
python -m nuitka --mingw64 --standalone --output-dir=out --show-progress --onefile main.py

You can save it as build.bat so you can open it and use it