Deltrance
Mobile Development 1 min read

How to fix 'zsh: command not found: python' ?

Mobile DevelopmentPythonShell
How to fix 'zsh: command not found: python' ?

When trying to run python from terminal, it is possible to run into the following issue:

zsh: command not found: python

This can happen on any system, but does occur slightly more commonly on MacOS since they removed native python support in MacOS 12.3. Fortunately this issue is easy to fix.

Step 1: make sure Python is installed

The first thing you should check is that python is installed. You can install python from terminal if you have brew installed by simply typing:

brew install python
Step 2: add python to zsh

The next step is to add python to zsh so that it will run upon typing the python command. You can do this by running the following in terminal:

echo "alias python=/usr/bin/python3" >> ~/.zshrc
Step 3: restart terminal

Now that you’ve done that, simply restart your terminal. When you open it again, your python command should work successfully.