1. The macOS system has integrated python3
The current macOS system (take my MacBook Air 15.3-inch M2 chip macOS Ventura system as an example) has already integrated the python environment, and the python command is used in the built-in terminal zsh.
/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9
Note: "/" represents the system root directory (Machintosh HD), "~" represents the user root directory (ie /Users/yuanchenglei under the root directory);
There is a Library in the root directory of the system, and a Library in the root directory of the user. Note that the built-in python is installed in the Library in the root directory.
But directly in the terminal, when the python command is executed, the following error is prompted?
The reason is that you used the wrong command, you should use python3 instead of python. Because python is considered python2.
After executing the python3 command, you can enter python smoothly.
2. Arrangement of pip knowledge points
Executing pip will report the same error, similar to the above, you should use pip3
View currently installed packages
pip3 list
View current pip sources
pip3 config list
Permanently modify pip sources
pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
Update pip to the latest version
python3 -m pip install --upgrade pip
3. Coding
Write this at the beginning, which is more concise than the version posted on the Internet
# coding=utf-8