Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Command Not Found Python Mac: Fix It Fast

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

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

  1. Open Terminal. Press Command+Space, type Terminal, and press Return. You can also find it in Applications > Utilities.
  2. Try the correct command name first. Type python3 --version and press Return. On current macOS versions, Python 3 is installed by default, but the command is python3, not python. If you see a version number like Python 3.12.4, Python is working. You can create an alias later if you want to type python.
  3. 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.
  4. Install the Xcode Command Line Tools. Many command-line tools, including a basic Python 3, come with these tools. Run xcode-select --install in Terminal. A dialog will appear; click Install and agree to the license. Wait for the download to finish (it can take several minutes). Then run python3 --version again.
  5. 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.
  6. Add Python to your PATH (only if python3 still 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: run ls /usr/local/bin/python3* or ls /opt/homebrew/bin/python3*. Then edit your shell profile. For macOS Catalina and later, the default shell is zsh, so edit ~/.zshrc with a text editor (for example, nano ~/.zshrc). Add a line like export PATH="/usr/local/bin:$PATH" (use the directory that contains your Python). Save, then run source ~/.zshrc. For older macOS using bash, edit ~/.bash_profile instead.
  7. Create an alias for python (optional). If you want the command python to work, add alias python=python3 to the same shell profile file, then reload it with source ~/.zshrc (or the file you edited).
  8. Verify everything works. Close Terminal and open a new window. Run python3 --version and, if you added the alias, python --version. Both should print a version number.

Common Mistakes

  • Typing python instead of python3. macOS does not ship a python command by default; it only provides python3. 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 with echo $SHELL.
  • Forgetting to reload the profile. After editing a profile file, you must run source ~/.zshrc or 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 or pip3 install --user instead.

Tips

  • Use python3 -m venv myenv to create isolated environments for projects, then activate with source myenv/bin/activate.
  • Check your PATH with echo $PATH to see which directories are searched for commands.
  • If you use Homebrew, install Python with brew install python and 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.