Compile Python on Windows

Looking to create an executable from Python script? Let me show you the full steps to achieve it on Windows .

Steps to create a Windows executable from a Python script using Nuitka

Step 1: Add Python to Windows Path

The simple way to add Python to the PATH do this is to check the box during installation of CPython. You just download python and install or modify Python by checking the box in the installer:

check modify PATH when you install python

This box is not enabled by default. You can also manually add the Python installation path to PATH environment variable.

Note

You do not strictly have to execute this step, you can also replace python with just the absolute path, e.g. C:\Users\YourName\AppData\Local\Programs\Python\Python310\python.exe but that can become inconvenient.

Step 2: Open a Windows Prompt

This can be cmd.exe or Windows Terminal, or from an IDE like Visual Code or PyCharm. And then type python to verify the correct installation, and exit to leave the Python prompt again.

Launch Python in Windows prompt to verify