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:
Bash
python -c "import sys; print(sys.executable)"
If you normally use python3, use:
Bash
python3 -c "import sys; print(sys.executable)"
Option B (alternative): Find it from the command line
Windows:
where.exe python
where.exe py
macOS/Linux:
Bash
which -a python
which -a 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
If you installed Python with the Python install manager (recommended by python.org; available from python.org/downloads or the Microsoft Store, or winget install 9NQ7512CXL7T -e), it provides the python, py and pymanager commands without editing PATH; if it offers to add %LocalAppData%\Python\bin to PATH, accept only if you want versioned commands like python3.14. If the commands don’t work, remove older Python folders from PATH that may take priority, make sure the Python (default) app execution aliases are on, then run pymanager install --configure (this works even if py is taken by the legacy launcher). The options below apply to the traditional python.org installer, which is deprecated since Python 3.14 and won’t be produced for 3.16 or later.
Option A (traditional installer): Re-run the installer and enable PATH
If you used the traditional python.org installer, rerun it 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:\Program Files\Python312\
Also add the Scripts folder for the same install so pip commands resolve correctly:
C:\Users\<you>\AppData\Local\Programs\Python\Python312\Scripts\C:\Program Files\Python312\Scripts\
Close all terminal windows, open a new one, then verify:
where.exe python
python --version
python -m pip --version
What to look for: in where.exe python, the first result is usually 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.
Disabling the python.exe and python3.exe aliases applies when you installed Python with the traditional installer and the alias opens the Store; if you use the Python install manager, keep its Python (default) aliases enabled, since its commands live under WindowsApps.
Check what runs:
where.exe python
If you used the traditional installer and 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:
where.exe python
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
which python
If which python doesn't point to pyenv's shims folder (~/.pyenv/shims by default) and no virtual environment is active, your shell init is probably 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
which python
What to look for: if pyenv is set up and no virtual environment is active, which python points to pyenv's shims folder in 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.
Bash
python -c "import sys; print(sys.executable)"
python -m pip --version
pip --version
On macOS/Linux, if you rely on python3, use:
Bash
python3 -c "import sys; print(sys.executable)"
python3 -m pip --version
pip3 --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:
where.exe python
python --version
python -m pip --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.
where.exe python
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
Bash
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.exe python to confirm PATH is updated.
If where.exe python shows WindowsApps, disable Microsoft Store app execution aliases (unless you use the Python install manager).
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.exe python (Windows) or which -a 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(unless you use the Python install manager). - Fix PATH on macOS/Linux only if your shell can’t find the right Python.
- Verify
sys.executableandpip --versionpoint to the same install.
Join 40M+ 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