DEV Community

Cover image for How to fix 'zsh: command not found: python'

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

Johnny Simpson on August 13, 2022

When trying to run python from terminal, it is possible to run into the following issue: zsh: command not found: python Enter fullscreen ...
Collapse
 
sixman9 profile image
Richard Joseph • Edited

I'm on an M1 Mac, the following worked for me as Step 2 (May 2023)

echo 'export PATH="$(brew --prefix)/opt/python@3/libexec/bin:$PATH"' >> ~/.zshrc

Found that at 'How do I use brew installed Python as the default Python?' on Stackoverflow.

Collapse
 
ahmad-ali14 profile image
Ahmad Ali

Thanks, this is super helpful

Collapse
 
chanzain profile image
Chan Zain

Thanks

Collapse
 
udit_rautela_ca940009ea3a profile image
udit rautela • Edited

thanks @smpnjn

Collapse
 
johnmalib profile image
johnmalib

This error occurs because the system-provided Python 2 installation has been removed from Apple's macOS as of macOS 11 Big Sur.

When Apple removed the system-provided Python 2 installation, it impacted users who were relying on it for their Python development environment. As a result, they may have encountered the error message zsh: command not found: python when trying to run the python command.

To resolve this issue, you need to install a newer version of Python (such as Python 3 ) or use a version manager like Homebrew or pyenv to manage your Python installations. These tools allow you to install multiple versions of Python and switch between them as needed.

Collapse
 
vijaykhatri96 profile image
Vijay Singh Khatri

@smpnjn You can also add this post in your reference list that can be beneficial fo user who want to understand the concept of brew command not found error.

Collapse
 
padunk profile image
Abraham A. Agung

this path work for me /usr/local/bin/python3

Collapse
 
reecestart profile image
Reece

Thanks

Collapse
 
vinodsharma profile image
Vinod Sharma

Thank you for your help

Collapse
 
swlkr_11 profile image
Sam Walker

THANK YOU SO MUCH

Collapse
 
__e22830f76744 profile image
Khaustoff

Thanks