MacOS Error zsh: Command not found: Python – Code Example
If you have updated MacOS Monterey to version 12.5+ then you can’t use python in commands to refer your Python program. This is removed from Monterey 12.5+. In order to work with it, simply replace all python reference from commands to python3 . Otherwise you will get Error zsh: Command not found: Python.
Why this happened?
The error suddenly started raising because Apple dropped the support of Python2 from MacOs Monterey 12.5+. xCode requires that you need to have version greater than 12.5. So, you need to update your OS. But update will break the Python.
Although Python2 is removed but Python3 is supported so you can still use that.
Solutions with Code Example
There are 2 solutions to this problem –
- Use Python3 instead of Python2
- Create python alias pointing to Python3 in zsh
- Install Python2 using pyenv
Let’s look at both these solutions separately.
Using Python3 instead of Python2
Referencing a command with python will try to invoke Python2 in zsh. But since Python2 is not available then we can reference out commands with python3. Check this code –
This code will raise zsh: Command not found: Python error. To resolve it, you need to run your file with python3 as shown in below code –
Create python alias pointing to Python3 in zsh
Everything will be sorted if you create an alias of python pointing to Python3. What this will do is instead of using Python2 for python reference, it will use Python3.
To create the alias, use this code –
Now if I run my python file using python command –
It will run without issues.
Install Python2 using pyenv
Although Python2 is not provided by MacOS, you can still install it using pyenv . Here are the steps –
1. Install pyenv using brew –
2. Check the list of all the versions of python available on pyenv –
3. Install a version suitable for your use –
4. Set this version as global version on your system –
/.zshrc and add the below code there –
6. Restart the terminal and try working again.
Conclusion
In this article we saw the reason of why MacOs Monterey is raising “command not found” error for python. Also, we learned about multiple solutions to solve this issue. After following the steps, you will be able to resolve it completely.
[Fix] zsh: command not found: python on Mac
There could be multiple reasons which can cause zsh: command not found: python when you try to run a Python program on the Mac Terminal. One of the most common reasons is that you have Python3 installed on your Mac

Fix 1: Use Python3 instead of Python
Fix 2: Install Python using brew
If Python is still missing install Python using Homebrew package manager for Mac,
Fix 3: Python Path is not set
You might already have Python installed but the path is not set. Update the path in .zshrc file.
Have Questions? Post them here!
report this ad
Know the Author: With a Masters Degree in Computer Science from the prestigious University of Mumbai, Rakesh is a highly experienced professional in the field. With over 18 years of practical expertise, he specializes in programming languages such as Java EE, Python, Sharepoint, PHP, and Rust. He has a proven track record in various industries, including Banking, Finance, and Insurance. His proficiency extends to a wide range of operating systems, including macOS, Ubuntu, Windows, CentOS, Fedora, and Arch Linux. Additionally, he is well-versed in web technologies such as HTML, CSS, and JavaScript, as well as popular frameworks like Spring Boot, Vue, React, and Angular. With a focus on Cybersecurity, DevOps, and AI & ML, Rakesh brings a wealth of knowledge and practical experience to his work. He is dedicated to delivering high-quality solutions and providing valuable insights to meet the unique challenges of the digital landscape. Feel free to reach out to him at rakesh@code2care.org.
We are celebrating the 10th years of Code2care! Thank you for all your support!
How can I fix the "zsh: command not found: python" error? (macOS Monterey 12.3, Python 3.10, Atom IDE, and atom-python-run 0.9.7)
Since I got the macOS v12.3 (Monterey) update (not sure it’s related though), I have been getting this error when I try to run my Python code in the terminal:

I am using Python 3.10.3, Atom IDE, and run the code in the terminal via atom-python-run package (which used to work perfectly fine). The settings for the package go like this:

The which command in the terminal returns the following (which is odd, because earlier it would return something to just which python ):

I gather the error occurs because the terminal calls for python instead of python3 , but I am super new to any coding and have no idea why it started now and how to fix it. Nothing of these has worked for me:
How to Fix Zsh: Command Not Found: Python [with Video]
Since Python 2’s system installation was removed from Apple’s macOS with the release of macOS Big Sur, these zsh command errors, for instance, zsh: command not found: pip, zsh: command not found: python vscode and other zsh issues appear more frequently.
When you try to run the Python command but it is not in your shell’s PATH, the error zsh: command not found: python will show on the Terminal or other servers. Alternatively, Python may not be installed, or its executable file may not be in the system’s PATH.
The other reason is the users who relied on the system-provided Python 2 installation for their Python development environment were impacted when Apple deleted it. As a result, they might have run into the «zsh: command not found» issue when attempting to execute the Python command.
To solve the «zsh: command not found: python» issue on Mac, check the quick navigation first:
| Workable Solutions | Step-by-step Troubleshooting |
|---|---|
| Fix 1. Ensure Python3 installed | Installing a more recent version of Python, such as Python 3, or using a version manager. Full steps |
| Fix 2. Use Python3 command | When Apple deleted the system-provided Python 2 installation, it impacted users. Full steps |
| Fix 3. Update the PATH | This error may appear if Python is not installed on your system or the Python executable. Full steps |
| Fix 4. Restart the Terminal | A configuration reset can be used to restart Mac Terminal. The steps to factory reset. Full steps |
How to Fix Zsh Command Not Found: Python
Particularly on macOS, the Python command can occasionally be configured incorrectly. You can try four fixes to fix the error — zsh: command not found: python:
Before you are going to fix the zsh: command not found: python on Mac, watch this video first. It provides you with a more quick and detailed solution.
- 00: 00 — Introduction
- 01: 26 — Enter «python» in the command line
- 02: 10 — Check the Python version in Finder
- 02: 38 — Enter python3 instead of python
Fix 1. Make Sure Python3 Is Installed
If you didn’t install Python 3 manually but updated your Mac, you may discover that the zsh can’t find the Python command. Anyone who updates to Monterey 12.3 on their Mac would discover that their copy of Python 2 is suddenly missing. This is due to Apple removing the Python 2 installation that was pre-installed on the machine.

Installing a more recent version of Python, such as Python 3, or using a version manager, such as Homebrew or pyenv, to manage your Python installations, will fix this problem. You can install various Python versions and switch between them using these tools. To get around this, follow the below steps to use pyenv to install Python 3.9.6 or any other specific version you need.
Step 1. To manage Python versions, install pyenv using brew: «brew install pyenv».
Step 2. You can view every installable version with the «pyenv install — list»
Step 3. Then, «Pyenv install 3.9.6» will install.
Step 4. Enter «Pyenv versions» returns a list of installed versions.
Step 5. «Pyenv global 3.9.6» sets the default Python version globally.
Step 6. If necessary, add «eval «$(pyenv init —path)» to «/.zprofile» or «/.bash_profile» .
Step 7. Run «$ source /.zprofile» to verify that Python still runs after reopening the shell.
As mentioned above, you should use the command: brew. If the zsh: command not found: brew error appears, the message’s indication that either Brew isn’t installed or the current installation is defective or damaged is the most obvious cause of the problem.
Fix 2. Use the Python3 Command Instead of Python
When Apple deleted the system-provided Python 2 installation, it impacted users who relied on it for their Python programming environment. As a result, they might have run into the zsh: command not found: python issue when attempting to execute the python command.
So, the easiest way to fix the zsh: command not found: python problem is to enter python3 instead of typing merely python in the command line.

Thus, ensure the version of Python on Mac and enter the correct and specific command (python2 or python3) when you run the Zsh.
Fix 3. Update the PATH
This error may appear if Python is not installed on your system or the Python executable is not in your shell’s PATH.
You can include Python’s executable in the PATH if it is installed but not currently there. You can accomplish this by including the subsequent line in your shell profile file (for instance, /.zshrc ):
To reload the profile file after adding the line, restart your terminal or use the command below your terminal:
Now, entering the command python should successfully begin the Python interpreter.

Fix 4. Reset or Restart the Terminal
A configuration reset can be used to restart Mac Terminal. The steps to factory reset a Mac terminal are as follows:
Step 1. Launch the Terminal program on your macOS device.
Step 2. In the menu bar, select the shell option by tapping on it.
Step 3. Select «Reset» from the menu, or you can press Option + Command + R on your Mac keyboard.

You can reset the Terminal State by doing the aforementioned procedures. On the Terminal screen, however, there won’t be any divergence visible.
If one of the methods is helpful to resolve the Zsh issue, share it on Facebook, Twitter, Instagram, and other social media platforms!
Extra-Tip: Recover Deleted Data and Applications on Mac
Why does the «zsh: command not found: python» error occur more commonly on macOS? Mac users might delete the local Python support after macOS 12 Monterey, especially macOS 12.3.
Thus, the zsh: command not found: python error may lead to data loss on Mac. That’s because website issues might also result in the Zsh error. Don’t worry. The issue is easy to resolve with the help of EaseUS Data Recovery Wizard for Mac.
Your Mac system is more susceptible to them when something like Zsh authorization is refused or directly tied to files. With EaseUS Data Recovery Wizard for Mac, you can get the deleted or lost data and applications back and recover permanently deleted files on Mac.
- ️EaseUS Data Recovery Wizard for Mac can quickly recover Trash Mac and recover data from formatted storage devices.
- It supports recovery of macOS and Windows system data for sudden deletion, formatting, hard drive corruption, virus attack, etc.
- It can recover and restore over 1000 file types and formats, including JPG, RAW, ART, XLTX, DOC, APE, M4A, etc.
Download EaseUS Data Recovery Wizard for Mac and recover data on Mac in three steps:
Step 1. Select the drive to be scanned
In the main EaseUS Data Recovery Wizard window, there will be a list of the drives connected to your Mac. Select the drive you need to recover lost/deleted files from, and click the «Search for lost files» button.

Step 2. Select your lost data/files
EaseUS Data Recovery Wizard for Mac will immediately scan your selected disk volume and display the scanning results on the left pane. You can sort the results to find the wanted files if you are looking for certain files.

Step 3. Recover lost/deleted data
Once you have found the desired files, preview the files and then click «Recover» to begin the recovery of your deleted/lost Mac files.

How to Add Python to Zsh
Even if Python is already installed, the path may not be configured. Thus, the next stage is to add Python to Zsh to launch when the Python command is entered. To accomplish this, open Terminal on Mac and execute the following commands in the terminal:
echo «alias python=/usr/bin/python3» >>
Your zsh profile will then be set up to launch /usr/bin/python3 whenever Python is used. Check that python=$, where the $ sign should equal the path python is installed on, if you are still having problems.
Instead of using zsh, you can use bash to perform the following actions:
echo «alias python=/usr/bin/python3» >>
Having a failed Python installation on your PATH is a typical problem. The command line will attempt to launch the corrupted executable if it is the first one it encounters and will stop looking for further corrupt files afterward. While you should also clear your system of the flawed Python installation, the quick cure for this is as simple as placing your new Python directory before the old Python directory.

The Bottom Line
Due to Python 2’s end-of-life, Apple removed the system-provided installation from macOS 11 Big Sur. This indicates that Python 2 is no longer regarded as a secure or dependable version of the language and is no longer actively supported by the Python development community. Thus, the zsh: command not found: python problem becomes more common.
This article provides 4 ways to solve the error. The Terminal is a helpful tool on Mac and a necessary utility to run the command. However, you may face horrible data loss if you can’t correctly use the Terminal on Mac. Fortunately, EaseUS Data Recovery Wizard for Mac can help!
Zsh Command Not Found: Python FAQs
You may have more questions about it after learning how to fix the zsh: command not found: python issue. See if you can find your answers here:
1. How do I fix commands not found in Python?
You must select the Path option. As you can see in the screen below, Python needs a path variable. If Python’s Path is absent, choose Path from the menu and click Edit. A new screen will appear; click New.
2. How do I run Python on the Mac terminal?
It is really simple to do on a Mac computer. All you have to do is launch Launchpad, look for Terminal, input Python into the terminal, and it will output the Python version for you.
3. How to fix the error — zsh command not found?
You can attempt the solutions listed below to resolve the zsh problem. You can click the linked page on how to resolve Zsh: command not found to read more.
- Configure Environment $Path
- Install the package
- Reinstall the macOS
- Check the.zshrc file’s Syntax Set Path.
4. How to delete files on Macbook with Terminal?
Step 1. Open Applications in the Finder window, then select Utilities to enter Terminal on your Mac.
Step 2. In the Terminal window, enter «rm» followed by a space. After that, drag a file into the Terminal to delete it.