The situation
You just installed Python, opened a new terminal, typed python --version, and got slapped with this:
'python' is not recognized as an internal or external command,
operable program or batch file.
Or maybe it was working yesterday and suddenly it stopped. Either way, your scripts are dead in the water and you need this fixed now.
What's actually wrong
Windows finds commands by scanning a list of directories called PATH. Type python and it searches each directory for a python.exe file. No match found, no command runs โ just that error.
The usual culprits:
- You installed Python but unchecked "Add Python to PATH" in the installer โ easy to miss, very common.
- Multiple Python versions are installed and conflicting with each other.
- Another install or uninstall modified or corrupted your PATH.
- The terminal was already open when you installed Python. Old sessions don't pick up new PATH changes.
Quick check first
Run this before touching any settings:
where python
A result like C:\Users\YourName\AppData\Local\Programs\Python\Python312\python.exe means Python is installed โ it's just missing from PATH. Nothing returned means Python isn't installed at all. Install it first, then come back.
Also worth trying:
py --version
Works here but not with python? The Windows Python Launcher is present, but the python alias isn't in PATH. The fixes below will sort that out.
Fix 1: Restart your terminal
Just installed Python? Close every open terminal window and open a fresh one. PATH changes don't propagate into already-running sessions. This alone fixes around 20% of cases โ worth trying before anything else.
Fix 2: Re-run the installer with "Add to PATH" checked
Skipped that checkbox during install? The cleanest fix is letting the installer add the path for you:
- Go to Settings โ Apps โ Installed Apps, find Python, click Modify.
- Select Modify again in the installer dialog.
- On the Optional Features screen, click Next.
- On Advanced Options, check "Add Python to environment variables".
- Click Install.
Open a fresh terminal and verify:
python --version
Fix 3: Add Python to PATH manually
Don't want to re-run the installer? Add the path directly.
Find your Python install location
where python
:: or if that fails:
dir /s /b C:\python.exe 2>nul
dir /s /b "%LOCALAPPDATA%\Programs\Python\python.exe" 2>nul
Common install locations:
C:\Users\YourName\AppData\Local\Programs\Python\Python312\C:\Python312\C:\Program Files\Python312\
Add two directories to PATH: the Python root (for python.exe) and the Scripts subfolder (for pip, pytest, and other tools).
Via System Properties (GUI)
- Press Win + R, type
sysdm.cpl, press Enter. - Go to Advanced โ Environment Variables.
- Under User variables, select Path and click Edit.
- Click New and add both paths on separate lines:
C:\Users\YourName\AppData\Local\Programs\Python\Python312 C:\Users\YourName\AppData\Local\Programs\Python\Python312\Scripts
- Click **OK** on all dialogs.
### Via PowerShell (faster)
Replace with your actual Python location
$pythonPath = "C:\Users$env:USERNAME\AppData\Local\Programs\Python\Python312" $scriptsPath = "$pythonPath\Scripts"
[System.Environment]::SetEnvironmentVariable( "Path", $env:Path + ";$pythonPath;$scriptsPath", [System.EnvironmentVariableTarget]::User )
Close and reopen your terminal after running this โ the current session won't reflect the change.
## Fix 4: Conflicting Python 2 and Python 3
Some setups map `python` to Python 2 and `python3` to Python 3. Check what's actually on your machine:
where python where python3 where py
Running Python 3 only? Make sure the Python 3 directory appears **before** any Python 2 directory in PATH. Open the Environment Variables dialog and use the **Move Up** button to reorder entries.
## Verify the fix
Open a **brand new** terminal โ don't reuse the old one โ and run all three:
python --version python -c "import sys; print(sys.executable)" pip --version
Expected output:
Python 3.12.x C:\Users\YourName\AppData\Local\Programs\Python\Python312\python.exe pip 24.x.x from ... (python 3.12)
All three working? You're done.
## Still not working?
Windows sometimes intercepts the `python` command and silently redirects it to the Microsoft Store. Check which binary is actually running:
In PowerShell
Get-Command python | Select-Object Source
Source showing something like `C:\Users\...\AppData\Local\Microsoft\WindowsApps\python.exe`? That's the stub โ a fake placeholder that opens the Store instead of running Python. Disable it:
- Open **Settings โ Apps โ Advanced app settings โ App execution aliases**.
- Toggle off **python.exe** and **python3.exe**.
- Reopen your terminal and retry.
With the stub gone, Windows will fall back to the real Python binary in your PATH.

