How to install and run Python on Windows
Windows 10 and Windows 11 do not include Python by default. You can install Python through the official installer or the Windows Package Manager, and execute scripts using PowerShell or Windows Terminal.
Step 1: Download and install Python on Windows
The Python Software Foundation publishes stable builds at python.org. For 64-bit Windows installations, download the Windows installer (64-bit) for Python 3.12.7.
Run the downloaded executable file named python-3.12.7-amd64.exe. On the first setup screen, select the checkbox labeled "Add python.exe to PATH" at the bottom of the dialog window. This setting registers the executable location in your Windows user environment variables.
Click "Install Now". On the final completion screen, click the option labeled "Disable path length limit" to remove the historic 260-character MAX_PATH limit in Windows.
Alternative installation: Windows Package Manager (winget)
Windows 11 and recent builds of Windows 10 include the winget package manager client. You can install Python directly from a command prompt without opening a web browser:
Step 2: Verify installation in PowerShell
Close any existing terminal windows so Windows loads the updated PATH environment variables. Open PowerShell by pressing Windows Key + X and selecting "Terminal" or "Windows PowerShell".
Run the following commands to confirm that the CPython interpreter and pip package manager respond:
Windows also provides the official launcher executable py.exe installed in C:\Windows\py.exe. This launcher detects all installed Python versions on your computer:
Step 3: Create and run your first Python script
Create a dedicated directory for your code on your primary drive. Open PowerShell and create a directory named python-projects:
Create a file named main.py using Windows Notepad or Visual Studio Code with the following program:
Execute the file by passing its name to the python command in PowerShell:
The script prompts for input and outputs the result in your terminal window before returning to the PowerShell command prompt.
Step 4: Set up virtual environments and install packages
Avoid installing third-party packages into the global Python root folder. Use the built-in venv module to create an isolated environment for each project.
Generate a local virtual environment named .venv inside your project directory:
Activate the environment by running the activation script:
If PowerShell displays an execution policy error such as PSSecurityException, configure script execution permissions for your current user account:
Once activated, the command prompt displays (.venv). You can now install libraries from PyPI without administrator privileges:
Troubleshooting Windows execution errors
Three setup issues account for most execution problems on Windows machines.
Windows opens Microsoft Store instead of running Python
Windows 10 and 11 install zero-byte executable shims in %LOCALAPPDATA%\Microsoft\WindowsApps. When Python is not on your PATH, Windows redirects typing python to the Microsoft Store. To fix this, open Windows Settings, navigate to Apps > Advanced app settings > App execution aliases, and turn off the toggles for "App Installer python.exe" and "App Installer python3.exe".
Script window closes instantly when double-clicked
File Explorer executes .py files in a temporary Command Prompt session that terminates as soon as the script completes. Run your scripts from an open PowerShell prompt, or add input("Press Enter to finish...") as the final line of your file.
UnicodeEncodeError with UTF-8 characters
Legacy Windows consoles use code page 437 (CP437) or Windows-1252. To enable UTF-8 mode across all Python processes on Windows, set the environment variable PYTHONUTF8=1 in your user settings, or run chcp 65001 in your terminal session before execution.
Windows local CLI versus browser runner
Review the structural differences between desktop terminal execution and in-browser WebAssembly runners.
| Capability | Windows local terminal | Browser WebAssembly runner |
|---|---|---|
| Installation needed | Yes (python.org or winget) | None (runs inside browser) |
| Path configuration | Requires PATH setup | Zero path setup |
| System disk access | Unrestricted NTFS disk read/write | Sandboxed virtual filesystem |
| Plot visualization | Requires desktop GUI window (Tk/Qt) | Inline visual Plots tab with PNG export |
Run Python scripts on Windows without installing software
Test Python 3.12 scripts, install PyPI packages, and inspect variables directly in Microsoft Edge or Google Chrome on Windows.
Launch Windows browser runner