Mac configures and installs the Python environment by downloading the package
1. Confirm whether the current system has installed Python
Enter the following command in the terminal:
python --version # Python 版本
python3 --version # Python3 版本
If the system has already installed Python, the version information of Python will be displayed. If Python is not installed, it needs to be downloaded and installed.
2. Download the Python installation package
You can download the Python installation package from the Python official website, download address .
3. Install Python
Open the downloaded installation package and follow the prompts to install it.
4. Configure environment variables
Enter the following command in the terminal:
open ~/.bash_profile
Add the following to the opened file:
export PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:${
PATH}"
Among /Library/Frameworks/Python.framework/Versions/3.8/bin 是 Python
them, the installation path needs to be modified according to the actual installation path.
You can view the Python path with the following command:
which Python3
Save the file and exit.
5. Make the environment variable take effect
Enter the following command in the terminal:
source ~/.bash_profile
7. Verify that Python is configured successfully
Enter the following command in the terminal:
python --version # Python 版本
python3 --version # Python3 版本
If the Python version information is output, it means that the Python configuration is successful.
8. install pip
Enter the following command in the terminal:
sudo easy_install pip # 安装pip
sudo easy_install pip3 # 安装pip3
9. Verify that pip is configured successfully
Enter the following command in the terminal:
pip --version
If the pip version information is output, it means that the pip configuration is successful.
At this point, the configuration of the Python environment is complete.