Quick Summary / Direct Answer: The ‘Python was not found’ error on Windows typically happens when the Python executable isn’t added to your system PATH during installation, or when Windows App Execution Aliases intercept the command. Fix it immediately by checking the ‘Add Python to PATH’ box in the installer, removing conflicting Microsoft Store aliases in Settings, or manually appending your Scripts and Python directories to the environment variables.
Key Takeaways:
- App Execution Aliases in Windows 10 and 11 often hijack the python.py and python3 commands, throwing silent or misleading errors when the Microsoft Store version isn’t installed.
- Manual PATH configuration requires pointing directly to both the root Python directory and the \Scripts\ subdirectory for pip and virtualenv to function correctly.
- Registry discrepancies between current user and system-wide installations frequently break command line resolution in terminal emulators like PowerShell or Git Bash.
It failed. You typed python into your terminal to spin up a quick script, and Windows flatly refused. No interpreter. No interactive shell. Just a sudden redirect to the Microsoft Store. When deploying development environments at scale or onboarding junior engineers, this is easily the most common friction point we hit. Most tutorials gloss over this edge case, but we are going to fix it permanently.
The Root Cause: Why Windows Loses Track of Python
Unlike Linux or macOS, which handle executable binaries via symlinks in standard directories like /usr/local/bin, Windows relies heavily on the Environment Path and the Windows Registry. If you install Python using an automated script or forget a tiny checkbox, the OS won’t know where python.exe lives.
Worse yet, Microsoft introduced App Execution Aliases to make installing utilities easier for non-developers. These aliases act as shims. When you type python, Windows checks these aliases first. If the alias is enabled but the actual Store package isn’t fully installed, it fails instantly.
Diagnostic Matrix: Pinpointing Your Specific Failure Mode
| Error Symptom | Primary Culprit | Immediate Resolution |
|---|---|---|
| Opens Microsoft Store instead of running Python | App Execution Alias enabled | Disable python.exe and python3.exe aliases in Windows Settings. |
| ‘Command not found’ in PowerShell or Command Prompt | Missing or broken system PATH variables | Add python root and \Scripts\ paths to Environment Variables. |
| Works in CMD but fails in VS Code terminal or Git Bash | Terminal-specific PATH caching or shell profile mismatch | Restart terminal emulator or configure shell-specific rc files. |
Step-by-Step Resolution Workflow
1. Neutralizing App Execution Aliases
Let’s tackle the most annoying culprit first. If typing python opens the Windows Store, your environment PATH might actually be fine, but the execution alias is overriding it.
- Open the Windows Start Menu and type Manage app execution aliases.
- Scroll down until you locate App installer entries for Python (typically
python.exeandpython3.exe). - Toggle these switches from On to Off.
Try your terminal again. If the alias was the bottleneck, your local installation will suddenly respond.
2. Repairing the System Environment PATH
If disabling aliases didn’t work, your machine simply doesn’t know where the binaries reside. Let’s fix the Environment Variables manually.
# Check current path variable in PowerShell
$env:Path -split ';' | Select-String 'Python'
If that command returns nothing, you need to add Python explicitly. Follow these steps:
- Press Win + R, type
sysdm.cpl, and hit Enter. - Navigate to the Advanced tab and click Environment Variables.
- Under System variables (or User variables), select Path and click Edit.
- Add these two paths (adjusting for your specific username and Python version):
C:\Users\YourUsername\AppData\Local\Programs\Python\Python311\
C:\Users\YourUsername\AppData\Local\Programs\Python\Python311\Scripts\ - Click OK across all windows, close your active terminal, and open a fresh instance.
3. Verifying Registry Integrity
Sometimes, broken registry keys prevent launchers from finding Python versions registered under HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE. Run the official installer executable again. Instead of a fresh install, select Modify, ensure Add Python to environment variables is checked, and run a repair. This rewrites the necessary registry entries without destroying your site-packages.