Python PATH Explained: Fix python Is Not Recognized and Command Line Issues
Quick Answer
PATH is the list of folders your terminal searches when you type a command like python, python3, py, or pip.
If Python is installed but your terminal cannot find it, either:
- Python is not on PATH
- the wrong Python appears first on PATH
- the terminal has not been restarted
- Windows App Execution Aliases are catching the command
- your IDE or notebook is using a different interpreter
Last verified: June 9, 2026.
Official Links
- Python on Windows: https://docs.python.org/3/using/windows.html
- Python on macOS: https://docs.python.org/3/using/mac.html
- Python on Unix/Linux: https://docs.python.org/3/using/unix.html
- Python downloads: https://www.python.org/downloads/
- Python documentation: https://docs.python.org/3/
- Homebrew: https://brew.sh/
What You Will Learn
By the end, you should be able to:
- explain PATH in plain language
- check which Python command your terminal is using
- fix Windows
python is not recognized - fix macOS
python3: command not found - understand
python,python3, andpy - install packages into the correct Python
1. What PATH Means
When you type:
python --versionyour terminal does not search your whole computer. It searches only folders listed in PATH.
If the Python executable is in one of those folders, the command works. If not, the command fails.
2. Windows Commands You Should Know
Open PowerShell and run:
python --version
py --version
py -0p
pymanager help
pymanager list
where.exe python
where.exe py
where.exe pymanagerWhat they mean:
| Command | Meaning |
|---|---|
python --version | Checks the default Python command |
py --version | Checks whichever py command Windows finds first |
py -0p | Lists installs when py is the legacy Python Launcher |
pymanager help | Shows Python Install Manager help |
pymanager list | Lists installs managed by Python Install Manager |
where.exe python | Shows the file path PowerShell uses for python |
where.exe py | Shows the file path PowerShell uses for py |
where.exe pymanager | Shows whether Python Install Manager is available |
In Windows Command Prompt, the equivalent commands are:
where python
where pyIf Python Install Manager owns py, py list can work. If legacy py.exe owns py, py list fails and you should use py -0p instead.
For Python 3.14+ through Python Install Manager, use:
pymanager exec -V:3.14 --version
pymanager exec -V:3.14 -m pip --versionFor Python 3.14 through legacy py.exe, use:
py -3.14 --version
py -3.14 -m pip --version3. macOS Commands You Should Know
Open Terminal and run:
python3 --version
python3 -m pip --version
which python3
echo $PATHWhat they mean:
| Command | Meaning |
|---|---|
python3 --version | Checks Python 3 |
python3 -m pip --version | Checks pip for that Python |
which python3 | Shows the Python path macOS is using |
echo $PATH | Shows all folders searched for commands |
On macOS, python3 is the reliable command. The plain python command may not exist.
4. Linux Commands You Should Know
python3 --version
python3 -m pip --version
which python3
echo $PATHOn Linux, do not manually replace system Python. Install project packages inside a virtual environment.
5. python vs python3 vs py
| Command | Usually used on | Notes |
|---|---|---|
python | Windows | Runs whichever Python appears first on PATH |
python3 | macOS/Linux | Usually the safest Python 3 command |
py | Windows | May be legacy Python Launcher or Python Install Manager |
py -0p | Windows | Lists installs with legacy Python Launcher |
pymanager list | Windows | Lists installs with Python Install Manager |
py -3.14 | Windows | Runs Python 3.14 with legacy Python Launcher |
pymanager exec -V:3.14 | Windows | Runs Python 3.14 with Python Install Manager |
Best beginner rule:
- Windows: use the exact command that matches your machine:
python, legacypy, orpymanager. - macOS: use
python3. - Linux: use
python3.
6. Why python -m pip Is Better Than pip
Plain pip can point to the wrong Python.
Use the Python command you already verified:
Windows:
py -m pip install requestsmacOS:
python3 -m pip install requestsLinux:
python3 -m pip install requestsThis means: run pip using this exact Python interpreter.
7. Fix python is not recognized On Windows
First close and reopen PowerShell.
Then run:
py --version
py -0p
pymanager list
where.exe py
where.exe pymanagerIf py works, Python is installed. You can keep learning with:
py script.py
py -m pip install package-nameIf py -0p works but py list fails, you have the legacy Python Launcher. That is usable. If pymanager list also works, you also have Python Install Manager installed separately.
If neither python nor py works:
- Reinstall Python from https://www.python.org/downloads/
- Use the Python Install Manager if offered.
- Open a new PowerShell window.
- Run
python --versionandpy --version.
If python opens the Microsoft Store:
- Open Windows Settings.
- Search for
App execution aliases. - Turn off aliases for
python.exeandpython3.exe. - Open a new terminal.
8. Fix PATH On macOS
If python3 is not found, install Python from python.org or Homebrew.
Then check:
which python3
echo $PATHIf you installed a tool and Terminal still cannot find it, restart Terminal.
If a tool asks you to add something to PATH, macOS zsh users usually update:
~/.zshrcThen reload it:
source ~/.zshrcDo not edit PATH randomly. Add only the folder requested by the official installer or tool documentation.
For Homebrew specifically, common paths are:
| Mac type | Common Homebrew path |
|---|---|
| Apple Silicon | /opt/homebrew/bin |
| Intel Mac | /usr/local/bin |
If Homebrew prints a brew shellenv command after install, follow that exact message. It usually adds Homebrew to your shell startup file so future Terminal windows can find brew, python3, and other tools.
Check Homebrew:
brew --version
which brew9. Scripts Folder And Package Commands
Some packages install command-line tools.
Examples:
jupyter
pytest
ruff
uvOn Windows, scripts often live in a Scripts folder inside Python or .venv.
On macOS/Linux, scripts often live in a bin folder inside Python or .venv.
Inside a virtual environment, activation places that folder first on PATH.
That is why this works after activation:
jupyter lab
pytest10. IDEs And Jupyter Can Use A Different Python
Your terminal might use one Python while VS Code, PyCharm, or Jupyter uses another.
Always check the interpreter inside the tool:
- VS Code: Command Palette ->
Python: Select Interpreter - PyCharm: Settings -> Project -> Python Interpreter
- Jupyter: Kernel -> Change Kernel
If a package imports in terminal but not in the IDE, the IDE is probably using a different Python.
Common Errors And Fixes
pip is not recognized
Use:
py -m pip --versionor:
python3 -m pip --versionModuleNotFoundError
You installed the package into one Python and ran code with another.
Check:
python -c "import sys; print(sys.executable)"or:
python3 -c "import sys; print(sys.executable)"Then install with that same command:
python3 -m pip install package-nameCommand works in old terminal but not new terminal
Check whether you activated a virtual environment in the old terminal. Activation changes PATH for that terminal session only.
FAQ
Should I manually edit PATH?
Only when an official installer or tool tells you exactly which folder to add. Most beginners can avoid manual PATH edits by reinstalling correctly and restarting the terminal.
Why does macOS use python3 instead of python?
It avoids conflicts with older system behavior. Use python3 for clarity.
Why does Windows have py?
Windows has had an older Python Launcher named py.exe for years. Python 3.14 also introduced Python Install Manager, which may use py if it owns that command. If py list fails with a legacy launcher warning, use py -0p or use pymanager list.
Why does pip install work but my code cannot import the package?
Because pip and your script are using different Python interpreters. Use python -m pip, python3 -m pip, or py -m pip.
Final Checklist
Windows:
python --version
py --version
py -0p
pymanager help
pymanager list
where.exe python
where.exe py
where.exe pymanager
py -m pip --versionmacOS:
python3 --version
python3 -m pip --version
which python3
echo $PATHLinux:
python3 --version
python3 -m pip --version
which python3If these commands make sense, Python PATH is no longer a mystery.
Next in this series: Mastering pip and PyPI: A Guide to Python Package Management →
