How to Fix 'zsh: command not found: python' by@smpnjn

How to Fix 'zsh: command not found: python'

MacOS has removed native python support in MacOS 12.3.3. The issue is easy to fix. Make sure Python is installed and add python to zsh so that it will run upon typing the `python` command. If you are still facing issues, ensure that `python=$` where the $ sign should equal the path `Python` is installed on. If you still face the same issue, move to step 2. Add python to your zsh profile to run `/usr/bin/python3` when `python is run.
image
Johnny Simpson HackerNoon profile picture

Johnny Simpson

Product, Engineering, Web

linkedin social icontwitter social iconinstagram social icongithub social icon


When trying to run python from the 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 the terminal if you have brew installed it by simply typing:


brew install python


You can also download the executable directly from the Python website to install it. Once python is installed, try running python from the terminal again. If you still face the same issue, move to step 2.


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


This will configure your zsh profile to run /usr/bin/python3 when python is run. If you are still facing issues, ensure that python=$ where the $ sign should equal the path python is installed on.


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.



Also published here.

react to story with heart
react to story with light
react to story with boat
react to story with money

Related Stories

L O A D I N G
. . . comments & more!