Python Is Not Recognized? Fixing PATH on Windows, Mac and Linux
Python is probably installed. Your terminal just can't find it. Check the three possible causes in order, fix the right one on Windows, Mac or Linux, and confirm which Python you're really running.
You installed Python. You typed python in the terminal. The terminal answers that it doesn't know what that is. Python is probably installed fine. The problem is that your terminal can't find it, and the list of places it looks is called PATH.
Skip ahead: If python --version (or python3 --version on Mac and Linux) already prints a version number, you don't need this tutorial. Go write code.
What the error actually means
Each system says it differently, but it's the same problem:
- Windows (Command Prompt):
'python' is not recognized as an internal or external command, operable program or batch file. - Windows (PowerShell):
The term 'python' is not recognized as the name of a cmdlet, function, script file, or operable program. - Mac and Linux:
command not found: pythonorpython: command not found
When you type a command, the terminal doesn't search your whole computer. It checks a short list of folders, in order, and runs the first match. That list is PATH. If the folder where python lives isn't in the list, the terminal gives up, even though the file is right there.
So there are only three possible causes:
- Python is not installed at all.
- Python is installed, but you're typing the wrong name for it.
- Python is installed, but its folder isn't in PATH.
Check them in that order. Don't start editing PATH before you know which one it is.
Step 1: Try the other names first
This fixes it for a lot of people, so try it before anything else.
On Windows, the official installer also installs the Python launcher, py:
py --version
On Mac and Linux, the command is usually python3, not python:
python3 --version
If either one prints something like Python 3.13.5, Python is installed and working. Use that name. On Mac and Linux, python3 is the normal name, not a workaround. Many systems don't have a plain python command at all, on purpose, so that old scripts written for Python 2 don't run with Python 3 by mistake.
💡 Tip: Inside an activated virtual environment, plain python works on every system. That's one more reason to use one per project.
Step 2: Windows, when nothing works
If python, py and python3 all fail on Windows, there are two likely cases.
**Case A: a Microsoft Store window opens, or python prints nothing.** Windows has "App execution aliases" that point python to the Store. If you installed Python from python.org, these aliases can get in the way. Open Settings > Apps > Advanced app settings > App execution aliases and turn off the two entries named python.exe and python3.exe. Close the terminal, open a new one, and try again.
Case B: the installer ran, but "Add python.exe to PATH" was not ticked. That checkbox is on the first installer screen, and it's off by default. The easiest fix is to run the installer again:
- Run the same installer you downloaded from python.org.
- Choose Modify, click Next, and tick Add Python to environment variables.
- Click Install, then close every open terminal and open a new one.
âš Warning: Don't edit PATH by hand if you can avoid it. In the Environment Variables window it's easy to delete the whole PATH value instead of adding one entry, and then many other programs stop working. The installer's Modify option does the same job without that risk. If you really have to edit it by hand, copy the old value into a text file first.
Close and reopen the terminal. A terminal reads PATH once, when it opens. Fixing PATH and then typing python in the same old window will fail again, and you'll think the fix didn't work. It did. The window just doesn't know yet.
Step 3: Mac and Linux, when python3 also fails
- Mac: typing
python3on a fresh Mac may offer to install the Command Line Developer Tools. That works, but it's an older Python managed by Apple. For learning, install the current version from python.org. The installer handles PATH for you. Open a new terminal afterwards. - Linux: most distributions already include
python3. If it's missing, install it with your package manager, for examplesudo apt install python3on Ubuntu or Debian.
If you want plain python on Ubuntu or Debian to mean Python 3, there's a package for that:
sudo apt install python-is-python3
âš Warning: On Linux, don't remove or replace the system Python, and don't change what /usr/bin/python3 points to. Parts of the operating system use it. Breaking it can break your package manager and desktop tools. Install extra versions next to it, never over it.
Step 4: Check which Python you're really running
Once a command works, confirm which Python it actually starts. If you have more than one installed, it might not be the one you think.
On Windows:
where python
py --list
On Mac and Linux:
which python3
You can also ask Python itself. This works everywhere:
import sys
print(sys.version)
print(sys.executable)
sys.version is the version, and sys.executable is the full path of the Python file that is running. If the path is not where you installed Python, there's a second installation earlier in PATH. Remember: the terminal runs the first match.
Common mistakes
- Typing the command inside Python. If you see
>>>, you're already inside Python.python --versionthere gives aSyntaxError. Typeexit()first. - Testing in the old terminal window. Close it after every install or PATH change.
- Installing again and again. Each install adds another copy. If the cause is the wrong name or an old terminal window, reinstalling changes nothing.
- Following a guide for the wrong system. Windows uses
pyandwhere. Mac and Linux usepython3andwhich.
What happens if you skip the check
You find a command that works, maybe through a full path you copied from somewhere, and you move on. Weeks later, pip install puts a package in one Python and your script runs with another. You get ModuleNotFoundError for a package you're sure you installed. It's the same PATH problem, just later and harder to see.
Two minutes now, or an evening later. If python and py print two different versions on your computer, which one is your editor using?
About
The three causes of 'python is not recognized' or 'command not found', and the fix for each on Windows, Mac and Linux. After this, you can tell which Python your terminal runs and why.
- Responsible
- Mary Q
- Last Update
- 09/18/2026
- Reading Time
- 6 min
Reviews
Sign in to write a reviewComments (0)
Sign in to commentNo comments yet.