MacOS installed python, and reported an error "zsh: command not found: python" [Solved]

1. Questions

homebrew installs python with the following command

brew install python3

Then use the following command to view the installed version of python

python --version

There will be an error:

zsh: command not found: python

 2. Solutions

2.1 Add python to zsh

Added pythonto zsh so it pythonruns when a command is typed. This can be done by running the following command in Terminal:

echo "alias python=/usr/bin/python3" >> ~/.zshrc

This configures your zsh profile to run at /usr/bin/python3runtime python. If you're still having trouble, make sure python=$ the $ sign should be equal to pythonwhere your installation path is

2.2 Restart the terminal

Or enter the following command:

source ~/.zshrc

At this point, pythonthe command should run successfully.

 ~> python --version                                                                                    
Python 3.8.9


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

Guess you like

Origin blog.csdn.net/baidu_30506559/article/details/127386192