How to Add Python to PATH
What you’ll build or solve
You’ll add Python to your PATH so you can run python, python3, and python -m pip from any terminal window.
When this approach works best
This approach works best when you:
Learn Python on Mimo
- Installed Python successfully, but
pythonis “not recognized” (Windows) or “command not found” (macOS/Linux). - Have Python installed, but the terminal keeps using the wrong version because another install is earlier in PATH.
- Want
python -m pipto install packages into the same Python you run.
Avoid this approach when:
- Your device is managed by work or school and you do not have permission to change environment variables.
- You are on Linux and you plan to change system-wide PATH in a way that could affect system scripts. Prefer user-level changes.
Prerequisites
- Python is already installed (or you know where your Python executable lives)
- A terminal you can restart (PowerShell, Command Prompt, Terminal, etc.)
- Permission to edit environment variables (Windows) or shell config files (macOS/Linux)
Step-by-step instructions
1) Find the Python executable you want to use
Start by locating the exact Python executable you want on PATH.
Option A (most common): Ask Python where it is
If python already runs in some terminals, use:
python-c"import sys; print(sys.executable)"
If you normally use python3, use:
python3-c"import sys; print(sys.executable)"
Option B (alternative): Find it from the command line
Windows:
wherepython
wherepy
macOS/Linux:
Bash
which python
which python3
What to look for: you may see multiple paths. Pick the one you want to run when you type python.
2) Add Python to PATH on Windows
Option A (most common): Re-run the installer and enable PATH
If you installed from python.org, rerun the installer and select:
- Modify
- Enable Add Python to environment variables (or check Add python.exe to PATH)
Open a new PowerShell window and verify:
python--version
python-c"import sys; print(sys.executable)"
Option B (alternative): Add PATH manually in Environment Variables
- Open Start, search for Environment Variables, then open Edit the system environment variables.
- Click Environment Variables…
- Under User variables (recommended), select Path → Edit.
- Click New and add the folder that contains
python.exe.
Common locations include:
C:\Users\<you>\AppData\Local\Programs\Python\Python312\C:\Python312\
Also add the Scripts folder for the same install so pip commands resolve correctly:
C:\Users\<you>\AppData\Local\Programs\Python\Python312\Scripts\
Close all terminal windows, open a new one, then verify:
CSS
wherepython
python--version
python-mpip--version
What to look for: in where python, the first result is what runs when you type python.
Fix Microsoft Store aliases if needed
Windows can route python to the Microsoft Store even when you installed Python elsewhere.
Check what runs:
wherepython
If you see a WindowsApps path, disable the aliases:
- Open Settings → Apps → Advanced app settings → App execution aliases
- Turn off python.exe and python3.exe
Then open a new terminal and verify:
CSS
wherepython
python--version
What to look for: the WindowsApps entry should disappear, and python should resolve to your real install.
3) Fix PATH on macOS (if needed)
Many macOS setups work without manual PATH edits, especially if you used Homebrew. This section is for cases where python3 exists but your shell can’t find it, or you’re picking up the wrong one.
First, check what your shell finds:
Bash
which python3
python3-c"import sys; print(sys.executable)"
Option A (most common): Homebrew Python
If you installed Python with Homebrew, add Homebrew’s bin directory to PATH.
Apple Silicon (common):
Bash
echo'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc
Intel Macs (common):
Bash
echo'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc
Reload your shell:
Bash
source ~/.zshrc
Verify:
Bash
which python3
python3--version
Option B (different approach): Use pyenv for multi-version management
pyenv manages Python versions and PATH automatically through shims. Use it if you switch between Python versions across projects.
Check what pyenv is doing:
Bash
pyenv versions
pyenv which python
If pyenv which python fails, your shell init is missing. Add pyenv init lines for your shell (zsh or bash) and restart the terminal.
What to look for: once pyenv is active, python usually points to a path under your home directory, not /usr/bin.
4) Fix PATH on Linux (if needed)
On Linux, python3 is often the default command. Many distros do not ship python at all.
Check what you have:
Bash
which python3
python3--version
Option A (most common): Add a user-level PATH entry
If your Python lives in a user location (for example, ~/.local/bin), add that directory to PATH in your shell config.
For bash:
Bash
echo'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
For zsh:
Bash
echo'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
Verify:
Bash
which python3
python3-c"import sys; print(sys.executable)"
Option B (different approach): Use pyenv for multi-version management
Bash
pyenv versions
pyenv which python
What to look for: if pyenv is set up, pyenv which python points into your home directory.
5) Verify the correct Python runs
Check which Python your terminal runs, and confirm pip is tied to the same Python executable.
python-c"import sys; print(sys.executable)"
python-m pip--version
On macOS/Linux, if you rely on python3, use:
python3-c"import sys; print(sys.executable)"
python3-m pip--version
What to look for: sys.executable and pip should belong to the same installation. If they don’t, fix PATH order or use python -m pip consistently.
Examples you can copy
Example 1: Windows manual PATH fix (Python + Scripts)
Add these two folders to your User PATH:
C:\Users\<you>\AppData\Local\Programs\Python\Python312\
C:\Users\<you>\AppData\Local\Programs\Python\Python312\Scripts\
Then verify:
CSS
wherepython
python--version
python-mpip--version
Example 2: macOS Homebrew PATH fix (Apple Silicon)
Bash
echo'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
which python3
python3--version
Example 3: Linux user PATH for local installs
Bash
echo'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
which python3
python3--version
Common mistakes and how to fix them
Mistake 1: Adding the wrong folder to PATH on Windows
What you might do: add the python.exe file path instead of the folder, or add a different Python folder than the one you want.
Why it breaks: PATH must contain directories, and Windows runs the first matching python.exe it finds.
Fix: add the install folder and Scripts folder, then check the order.
wherepython
python-c"import sys; print(sys.executable)"
Move the desired Python folder higher in PATH (or uninstall the one you do not want).
Mistake 2: Installing packages with pip, but imports still fail
What you might do: run pip install <package>, and later your script cannot import it.
Why it breaks: pip may be tied to a different interpreter than your Python executable.
Fix: run pip through the same Python executable
python-m pip install requests
python-c"import requests; print(requests.__version__)"
Troubleshooting
If you see “python is not recognized” on Windows, reopen the terminal, then run where python to confirm PATH is updated.
If where python shows WindowsApps, disable Microsoft Store app execution aliases.
If you see python: command not found on macOS/Linux, use python3 or fix PATH for your install method.
If your terminal runs the wrong version, check PATH order with where python (Windows) or which python3 (macOS/Linux).
If you get permission errors editing shell files, edit user-level files like ~/.zshrc or ~/.bashrc, not system files.
Quick recap
- Locate the Python executable you want to run.
- Add the correct directory to PATH (and Scripts on Windows).
- Disable Microsoft Store aliases on Windows if they hijack
python. - Fix PATH on macOS/Linux only if your shell can’t find the right Python.
- Verify
sys.executableandpython -m pippoint to the same install.
Join 35M+ people learning for free on Mimo
4.8 out of 5 across 1M+ reviews
Check us out on Apple AppStore, Google Play Store, and Trustpilot