Last modified: May 26, 2025 By Alexander Williams
How to Install Nuitka for Python
Nuitka is a Python compiler that converts your scripts into standalone executables. It improves performance and makes distribution easier.
This guide will walk you through installing Nuitka on different operating systems. You'll also learn basic usage with examples.
Prerequisites for Installing Nuitka
Before installing Nuitka, ensure you have Python installed. If not, check our guide on how to install Python on Ubuntu.
You'll also need pip, Python's package manager. Most Python installations include pip by default.
Verify your Python installation with:
python --version
Python 3.9.7
Installing Nuitka with pip
The easiest way to install Nuitka is using pip. Run this command:
pip install nuitka
This installs Nuitka globally. For local installation, consider using virtual environments.
Verify the installation with:
nuitka --version
0.6.19.5
Installing Nuitka on Different Operating Systems
Windows Installation
On Windows, use the same pip command. You might need to install Visual Studio for C++ compiler support.
Install the build tools from Microsoft's official website.
macOS Installation
For macOS, install Xcode command line tools first. Then use pip as shown above.
If you use Homebrew, check our guide on installing Python on macOS first.
Linux Installation
On Linux, install development tools first. For Ubuntu/Debian:
sudo apt-get install gcc python3-dev
Then install Nuitka with pip as before.
Basic Usage of Nuitka
Create a simple Python script to test Nuitka. Save this as hello.py:
# Simple test script
def main():
print("Hello from Nuitka!")
if __name__ == "__main__":
main()
Compile it with this command:
nuitka --standalone hello.py
The --standalone
flag creates a self-contained executable.
Run the compiled program:
./hello.bin
Hello from Nuitka!
Advanced Compilation Options
Nuitka offers many compilation options. Here are some useful ones:
Enable optimizations:
nuitka --standalone --enable-optimizations hello.py
Create a onefile executable:
nuitka --standalone --onefile hello.py
Include data files:
nuitka --standalone --include-data-files=*.txt=. hello.py
Troubleshooting Common Issues
If you get compiler errors, ensure you have all dependencies installed. On Linux, install development packages.
For missing module errors, use the --follow-imports
flag:
nuitka --standalone --follow-imports hello.py
Memory issues can be solved by increasing system swap space or using --low-memory
flag.
Conclusion
Nuitka is a powerful tool for compiling Python scripts. It can improve performance and make distribution easier.
Remember to install all required dependencies before compiling. Start with simple scripts before moving to complex projects.
For similar tools, check our guide on installing Cython.