Zsh Command Not Found Python Mac: Fix It Fast
In this article
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
- Check what Python versions are already available. Open Terminal (Applications > Utilities > Terminal) and run
python3 --version. If it prints a version likePython 3.x.x, Python 3 is installed. Also runwhich python3to see its path. Ifpython3works butpythondoes not, you only need an alias (step 4). If neither works, continue to step 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
python3command 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. - Alternatively, install via Homebrew. If you use Homebrew, run
brew install python. Homebrew installs Python 3 and creates apython3symlink in/opt/homebrew/bin(Apple Silicon) or/usr/local/bin(Intel). Homebrew does not create apythoncommand by default to avoid conflicts with system Python. - Create a shell alias for
python. To makepythonwork, add an alias to your zsh configuration file. Open or create~/.zshrcin a text editor (e.g.,nano ~/.zshrc) and add the line:alias python=python3. Save and exit. Then runsource ~/.zshrcto reload the configuration. Now typingpythonwill invoke Python 3. - Verify the fix. Close and reopen Terminal, then run
python --version. It should print the Python 3 version. Also testpython3 --versionto confirm both work. - If you prefer not to use an alias, always call
python3. Many modern tools and scripts expectpython3. You can update your workflow to usepython3andpip3instead ofpythonandpip.
Common Mistakes
- Editing the wrong shell profile. zsh reads
~/.zshrc, not~/.bash_profileor~/.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 runsource ~/.zshrcor open a new Terminal window for changes to apply. - Assuming
pythonis installed by default. macOS no longer ships with apythoncommand; onlypython3may be present (and even that is not guaranteed on a fresh system). - Using
sudoto install packages globally. Avoidsudo pip install; it can modify system Python and cause issues. Use virtual environments orpip3 install --userinstead. - 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 myenvto create isolated environments for projects, then activate withsource myenv/bin/activate. - Check your
PATHwithecho $PATHto ensure the directory containing Python 3 is included. - If you use multiple Python versions, consider
pyenvto 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.