Skip to content
Happy Programming Guide
Start learning
Python

Fixing “‘python’ is not recognized” in cmd and PowerShell

Python is installed but Windows cannot find it. The cause is a missing PATH entry or the Microsoft Store alias. Three fixes, from quickest to most permanent.

A code editor open on a laptop screen

'python' is not recognized as an internal or external command, operable program or batch file means Windows looked through every folder on the PATH and found no python.exe. Python may well be installed; the installer simply did not add its folder to the list, or a Windows setting is intercepting the command. There are three fixes, and the quickest takes ten seconds.

First: does the py launcher work?#

POWERSHELL
py --version
py -0

The python.org installer adds a launcher called py that is always on the PATH. If py --version prints a version, Python is installed and working; only the python name is missing. You can use py everywhere you would use python, including py -m pip install requests, and skip the rest of this article if that is enough.

py -0 lists every Python the launcher knows about.

Fix 1: the Microsoft Store alias#

Windows ships with fake python.exe and python3.exe files that open the Microsoft Store. If typing python opens the Store, or does nothing, this is the cause — and it sits ahead of your real installation on the PATH.

  1. Open Settings, then Apps, then Advanced app settings, then App execution aliases.
  2. Turn off the two entries labelled App Installer python.exe and App Installer python3.exe.
  3. Open a new terminal and try again.

This is the fix for the case where Python is installed, the PATH looks right, and it still does not work.

Fix 2: re-run the installer#

The python.org installer has a checkbox, unticked by default, labelled Add python.exe to PATH. Most people miss it. Run the installer again, choose Modify, go to Advanced Options, tick the PATH box, and finish. It rewrites the PATH correctly and this is the least error-prone permanent fix.

Fix 3: add it to the PATH yourself#

First find where Python is:

POWERSHELL
dir "$env:LOCALAPPDATA\Programs\Python"
dir "C:\Program Files\Python*"
py -c "import sys; print(sys.executable)"

Then add two folders to the PATH: the one containing python.exe, and its Scripts subfolder, which is where pip and other installed commands live.

  1. Press the Windows key, type environment variables, open Edit environment variables for your account.
  2. Select Path under user variables, click Edit, then New.
  3. Add C:\Users\you\AppData\Local\Programs\Python\Python313 (your actual folder).
  4. Add the same path with \Scripts on the end.
  5. Use Move Up to put both above any WindowsApps entry.
  6. OK all the way out.

Or from PowerShell, for the current user:

POWERSHELL
$py = "$env:LOCALAPPDATA\Programs\Python\Python313"
$old = [Environment]::GetEnvironmentVariable("Path", "User")
[Environment]::SetEnvironmentVariable("Path", "$py;$py\Scripts;$old", "User")

Putting the new entries at the front means they win over the Store alias.

pip is not recognized too#

Same cause. pip lives in the Scripts folder, so if that is not on the PATH, pip is not found either. Until it is fixed, run pip through the interpreter instead:

POWERSHELL
py -m pip install requests
python -m pip install requests

Using -m pip is worth keeping as a habit anyway. It guarantees pip installs into the Python you are running, which matters as soon as you have more than one.

Checking which one runs#

POWERSHELL
where.exe python           # every python.exe on the PATH, first one wins
python -c "import sys; print(sys.executable)"

If where lists a WindowsApps path first, the Store alias is still ahead of your install: go back to Fix 1 or reorder the PATH. If it lists an old version first, move the newer folder above it.

Inside VS Code#

VS Code chooses an interpreter separately from the PATH. If the terminal works but the editor says Python is not found, open the command palette and run Python: Select Interpreter, then pick the one you installed. That setting is per workspace.

Python 3.14 and later#

Recent installers offer a Windows Package Manager path as well as the classic installer, and the folder layout can differ slightly. The diagnosis does not change: py -0 shows what is installed, where.exe python shows what the PATH finds, and the fix is making the second agree with the first.

Questions people ask#

Should I use py or python?

Either works once the PATH is right. py is handy for choosing a version, as in py -3.12. Tutorials mostly say python, so it is worth getting that working.

Do I need to reinstall Python?

No. Every fix here keeps the existing installation. Reinstalling only helps if you use it to tick the PATH checkbox.

Why does python3 not work on Windows?

The python.org installer only creates python.exe. Use python or py; the python3 name is a Linux and macOS convention.

It works in cmd but not in PowerShell, or the other way round.

They read the same PATH, so the difference is nearly always that one window was opened before the change and the other after. Close both and reopen.

Where to go next#

Python not working in the VS Code terminal: choosing the interpreterRead next

Keep reading

Keep going — pick your next guide

The fastest way to improve is to read one guide, then build the thing it describes. Start with the basics, or jump straight to a project.

Ask a question or share what worked

Your email address will not be published. Required fields are marked *