{"id":3715,"library":"nuitka","title":"Nuitka Python Compiler","description":"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.","status":"active","version":"4.0.8","language":"en","source_language":"en","source_url":"https://github.com/Nuitka/Nuitka","tags":["compiler","executable","standalone","packaging","performance","optimization","distribution"],"install":[{"cmd":"pip install Nuitka","lang":"bash","label":"Install Nuitka"}],"dependencies":[{"reason":"Nuitka translates Python to C code, which then requires a C compiler (e.g., MSVC/MinGW-w64 on Windows, GCC/Clang on Linux/macOS) to produce machine code.","package":"C Compiler","optional":false},{"reason":"Highly recommended for significantly faster repeated compilations of generated C code.","package":"ccache","optional":true},{"reason":"For Nuitka running on Python 3.4, an additional Python 2 or Python 3.5+ installation is required at compile time due to internal Scons tool compatibility issues.","package":"Python 2 or 3.5+","optional":true},{"reason":"Required for compression when using the --onefile option. Not installed by default with Nuitka 4.0+.","package":"zstandard","optional":true}],"imports":[{"note":"Nuitka is primarily a command-line tool. Using 'python -m nuitka' ensures it runs with the intended Python interpreter.","symbol":"Nuitka via command line","correct":"python -m nuitka your_script.py"}],"quickstart":{"code":"print('Hello, Nuitka!')","lang":"python","description":"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."},"warnings":[{"fix":"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.","message":"Nuitka requires a compatible C compiler to be installed and correctly configured on your system (e.g., Visual Studio/MinGW-w64 on Windows, GCC/Clang on Linux/macOS). Missing or misconfigured compilers are a common initial setup hurdle.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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.","message":"When compiling in `--standalone` or `--onefile` mode, Nuitka might not automatically detect all data files (e.g., configuration files, images, model files) used by your application. This can lead to `FileNotFoundError` at runtime.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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.","message":"The `--onefile` option, while convenient, can be more complex to debug for missing files and may result in slower startup times due to the unpacking process. `--standalone` (which creates a distribution folder) is generally recommended for initial testing and debugging.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Replace `nuitka your_script.py` with `python -m nuitka your_script.py` in your build commands.","message":"Always invoke Nuitka using `python -m nuitka` instead of just `nuitka`. This ensures Nuitka runs with the specific Python interpreter you intend, preventing issues like `SyntaxError` or `ImportError` if multiple Python versions are present on your system.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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.","message":"Nuitka can compile Python modules into CPython extension modules, but these cannot be directly executed using `python -m <compiled_module_name>`. Python's `-m` flag expects source code or a specific module structure that compiled extensions do not provide.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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.","message":"Compiled Nuitka programs are designed to be stable, but segfaults or unexpected crashes can sometimes occur due to Nuitka bugs, unusual runtime conditions, or issues within third-party C/C++ extension modules.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}