Nuitka is a Python compiler that transforms Python scripts and modules into optimized C code, which is then compiled into standalone executables or extension modules. It aims to improve execution performance, offer better source code obfuscation, and simplify application distribution by bundling all dependencies. Compatible with CPython versions 2.6, 2.7, and 3.4-3.13, it supports Windows, macOS, and Linux. The current stable version is 4.0.8, with an active development cadence including frequent updates and new major releases.
pip install NuitkaVerified import paths — ran on the pinned version, not inferred.
Create a file named `hello.py` with the content above, then compile it into a standalone executable. Run the executable from the `hello.dist` directory.
Ensure a supported C compiler is installed and accessible in your system's PATH. Nuitka may offer to download one on Windows. For detailed setup, consult the Nuitka documentation.
Manually include necessary data files or directories using `--include-data-files=<source_path>=<destination_path>` or `--include-data-dir=<source_dir>=<destination_dir>` options during compilation.
Start with `--standalone` to ensure your application works correctly, then switch to `--onefile` once all dependencies and data files are correctly handled and you are comfortable with the trade-offs.
Replace `nuitka your_script.py` with `python -m nuitka your_script.py` in your build commands.
Import the compiled extension module into another Python script and call its functions (e.g., `import compiled_module; compiled_module.main()`) or wrap it with a small executable script.
If a compiled program crashes, recompile it with the `--debug` flag. This adds runtime checks and often transforms a segfault into a more informative assertion error, aiding in diagnosis. Additionally, check for missing data files or implicit imports.