How to compile python into executables for distribution.
- Nuitka
2.3.9
currently supports Python3.12.3
- pyenv | pyenv for Windows - Manage multiple python versions
# list available py versions
pyenv install -l
# install version
pyenv install 3.12.3
# set version
pyenv global 3.12.3
# update pip
python -m pip install --upgrade pip
# install project packages
pip install -r requirements.txt
The packages will need to be re-installed if you change python versions.
# install / update compiler
python -m pip install -U nuitka
# create executable
python -m nuitka generate.py
Additional information can be found on the Nuitka Tutorial Setup and Build page.
Package | Size |
---|---|
Numpy | 10 MB |
Python | 6 MB |
Pillow | 3 MB |
Other | 1 MB |
TOTAL | 20 MB |
The final app size is relatively large since pre-compiled package dll's get bundled into the executable, rather than getting tree-shaken / re-built. This results in a lot of dead code, but the end result is much more portable and user friendly.