Smart Systems for Home

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

Zsh 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

On macOS, zsh is the default shell, and seeing zsh: command not found: python means your shell cannot find a program named python in any directory listed in your PATH. The quickest fix is to install Python 3 (if it is not already installed) and either call it as python3 or create a shell alias so python points to it. This guide walks through safe, official methods to resolve the error without breaking your system Python.

What You'll Need

  • A Mac running macOS with Terminal access (zsh is the default shell since macOS Catalina; older versions may use bash, but the steps are similar).
  • Administrator password for installing software via Homebrew or the official Python installer.
  • An internet connection to download tools.
  • Basic familiarity with typing commands in Terminal.

Step-by-Step

  1. Check what Python versions are already available. Open Terminal (Applications > Utilities > Terminal) and run python3 --version. If it prints a version like Python 3.x.x, Python 3 is installed. Also run which python3 to see its path. If python3 works but python does not, you only need an alias (step 4). If neither works, continue to step 2.
  2. Install Python 3 using the official installer. Go to python.org/downloads and download the latest macOS installer. Open the .pkg file and follow the prompts. This installs Python 3 and the python3 command in /usr/local/bin (or /Library/Frameworks/Python.framework/Versions/3.x/bin). The installer may offer to add Python to your PATH; accept that option if prompted.
  3. Alternatively, install via Homebrew. If you use Homebrew, run brew install python. Homebrew installs Python 3 and creates a python3 symlink in /opt/homebrew/bin (Apple Silicon) or /usr/local/bin (Intel). Homebrew does not create a python command by default to avoid conflicts with system Python.
  4. Create a shell alias for python. To make python work, add an alias to your zsh configuration file. Open or create ~/.zshrc in a text editor (e.g., nano ~/.zshrc) and add the line: alias python=python3. Save and exit. Then run source ~/.zshrc to reload the configuration. Now typing python will invoke Python 3.
  5. Verify the fix. Close and reopen Terminal, then run python --version. It should print the Python 3 version. Also test python3 --version to confirm both work.
  6. If you prefer not to use an alias, always call python3. Many modern tools and scripts expect python3. You can update your workflow to use python3 and pip3 instead of python and pip.

Common Mistakes

  • Editing the wrong shell profile. zsh reads ~/.zshrc, not ~/.bash_profile or ~/.bashrc. If you add the alias to a bash file, it will not take effect in zsh.
  • Forgetting to reload the shell. After editing ~/.zshrc, you must run source ~/.zshrc or open a new Terminal window for changes to apply.
  • Assuming python is installed by default. macOS no longer ships with a python command; only python3 may be present (and even that is not guaranteed on a fresh system).
  • Using sudo to install packages globally. Avoid sudo pip install; it can modify system Python and cause issues. Use virtual environments or pip3 install --user instead.
  • Overwriting the system Python. Do not replace /usr/bin/python; it is reserved by Apple. Use aliases or install a separate Python 3.

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 ensure the directory containing Python 3 is included.
  • If you use multiple Python versions, consider pyenv to manage them, but install it via Homebrew and follow its documentation.
  • Keep your Python installation updated via the official installer or brew upgrade python.

Troubleshooting

If python --version still fails after creating the alias, check that the alias line is in ~/.zshrc and that you have reloaded the file. Run alias python to see if the alias is defined. If python3 itself is not found, verify that Python 3 is installed by running ls /usr/local/bin/python3 or ls /opt/homebrew/bin/python3 (depending on your setup). If the file exists but is not found, your PATH may be missing that directory; add it to ~/.zshrc with export PATH="/usr/local/bin:$PATH" (adjust path as needed). If you installed via Homebrew but brew is not found, you need to install Homebrew first. For permission errors, ensure you are not using sudo unnecessarily. If you accidentally modified system files, you may need to restore from a backup or reinstall macOS components; contact Apple Support if unsure.

Frequently Asked Questions

Why does macOS not have a python command?

Apple removed the Python 2 interpreter in recent macOS versions. Python 3 is available as python3, but the python command is not provided by default to avoid ambiguity.

Can I just use python3 instead of creating an alias?

Yes, using python3 is the recommended approach. Many tools and tutorials now use python3 explicitly. The alias is for convenience if you prefer typing python.

Will creating an alias break anything?

No, an alias only affects your interactive shell sessions. It does not modify system files or affect scripts that call python3 directly.

How do I uninstall Python if I installed it manually?

If you used the official installer, run the uninstall script located in the Python installation folder, or use brew uninstall python if installed via Homebrew. Be careful not to remove system Python.

What if I get a permission denied error when running python?

This usually means the file is not executable or you lack permissions. Check with ls -l $(which python3) and ensure it has execute permissions. If not, you may need to reinstall Python.

Does this fix work on both Intel and Apple Silicon Macs?

Yes, the steps are the same, but Homebrew paths differ: /usr/local/bin for Intel and /opt/homebrew/bin for Apple Silicon. Adjust PATH exports accordingly.