Command Not Found Python Mac: Fix It Fast
In this article
If you type python in Terminal on a Mac and get command not found: python, it usually means the Python 3 interpreter is not on your PATH, or you are calling the wrong command name. The fastest fix is to run python3 instead of python. If that also fails, you need to install Python 3 or add it to your shell PATH. This guide walks you through each check in order, from the simplest to the most involved, so you can get a working Python command without guessing.
What You'll Need
- A Mac running macOS Monterey or later (the steps also work on older versions with minor differences).
- Access to Terminal (found in Applications > Utilities, or via Spotlight search).
- An administrator account if you need to install software.
- An internet connection to download Python or the Xcode Command Line Tools.
Step-by-Step
- Open Terminal. Press Command+Space, type Terminal, and press Return. You can also find it in Applications > Utilities.
- Try the correct command name first. Type
python3 --versionand press Return. On current macOS versions, Python 3 is installed by default, but the command ispython3, notpython. If you see a version number likePython 3.12.4, Python is working. You can create an alias later if you want to typepython. - Check whether Python is installed at all. Run
which python3. If it returns a path such as/usr/bin/python3, the interpreter exists. If it returns nothing, continue to the next step. - Install the Xcode Command Line Tools. Many command-line tools, including a basic Python 3, come with these tools. Run
xcode-select --installin Terminal. A dialog will appear; click Install and agree to the license. Wait for the download to finish (it can take several minutes). Then runpython3 --versionagain. - Install Python 3 from python.org if needed. If the previous step did not give you Python 3, download the official macOS installer from python.org. Open the .pkg file and follow the installer. After installation, open a new Terminal window and run
python3 --version. - Add Python to your PATH (only if
python3still fails). The official installer usually adds Python to/usr/local/bin, which is already on your PATH. If you installed via Homebrew or a custom location, you may need to add it. First, find where Python is: runls /usr/local/bin/python3*orls /opt/homebrew/bin/python3*. Then edit your shell profile. For macOS Catalina and later, the default shell is zsh, so edit~/.zshrcwith a text editor (for example,nano ~/.zshrc). Add a line likeexport PATH="/usr/local/bin:$PATH"(use the directory that contains your Python). Save, then runsource ~/.zshrc. For older macOS using bash, edit~/.bash_profileinstead. - Create an alias for
python(optional). If you want the commandpythonto work, addalias python=python3to the same shell profile file, then reload it withsource ~/.zshrc(or the file you edited). - Verify everything works. Close Terminal and open a new window. Run
python3 --versionand, if you added the alias,python --version. Both should print a version number.
Common Mistakes
- Typing
pythoninstead ofpython3. macOS does not ship apythoncommand by default; it only providespython3. This is the most frequent cause of the error. - Editing the wrong shell profile. If you use zsh (the default since macOS Catalina), changes must go in
~/.zshrc, not~/.bash_profile. Check your shell withecho $SHELL. - Forgetting to reload the profile. After editing a profile file, you must run
source ~/.zshrcor open a new Terminal window for changes to take effect. - Installing Python but not restarting Terminal. The PATH is read when Terminal starts, so a new window is often needed.
- Using sudo to install packages globally. Avoid running
sudo pip install; it can break system Python. Use virtual environments orpip3 install --userinstead.
Tips
- Use
python3 -m venv myenvto create isolated environments for projects, then activate withsource myenv/bin/activate. - Check your PATH with
echo $PATHto see which directories are searched for commands. - If you use Homebrew, install Python with
brew install pythonand follow the caveats it prints. - Keep your shell profile tidy: add PATH changes at the end of the file and comment them for future reference.
Troubleshooting
If python3 --version still fails after installation, first confirm the installer finished without errors. Then check that the Python binary exists by running ls -l /usr/local/bin/python3 (or the path shown by the installer). If the file is missing, reinstall Python. If the file exists but the command is not found, your PATH is likely missing that directory; add it as described in step 6. Also ensure you are using the correct shell profile file. If you see a permission error, do not use sudo to run Python; instead, fix ownership of the relevant directories or use a virtual environment. For persistent issues, run which -a python3 to see all matching paths and check for conflicting installations. Finally, restart your Mac to clear any stale environment variables.
Frequently Asked Questions
Why does my Mac say python command not found?
Because macOS does not include a python command by default; it provides python3. Use python3 or create an alias.
Do I need to install Python on a new Mac?
Most Macs come with Python 3 preinstalled via the Xcode Command Line Tools. You only need to install it if python3 --version fails.
How do I make python work instead of python3?
Add alias python=python3 to your shell profile (e.g., ~/.zshrc) and reload it.
Can I use Homebrew to install Python?
Yes. Run brew install python and follow the instructions. Homebrew installs to /opt/homebrew/bin on Apple Silicon or /usr/local/bin on Intel, which are usually on your PATH.
What if python3 works but pip is not found?
Use python3 -m pip instead of pip. You can also install pip with python3 -m ensurepip.
Is it safe to change my PATH?
Yes, as long as you add directories rather than replacing the entire PATH. Back up your profile file before editing.