Install python3 in mac environment

1. View the python version on the current mac

- first open terminal

1. After opening, enter python3 to determine whether python3 has been installed on the computer. If you enter python, check the built-in version on the mac

 Command: python3【Enter directly】

The following page appears, indicating that python3 has been installed [When exiting, you can enter: exit () and press Enter]

If the following page appears, it means that python3 does not exist yet (my computer is already installed. So it can only be displayed in code form)

Two, install python3

  • 1. The first method brew installs python3: brew install python3
  • 2. The second method is to download from the official website [Link:  Python Releases for macOS | Python.org .] Download the version you need according to your needs

 

3. Install pip

Introduction to pip: pip is a Python package management tool that provides functions for searching, downloading, installing, and uninstalling Python packages.

If you download the latest version of the installation package from python.org, it already comes with this tool.

Python 2.7.9 + or Python 3.4+ and above all have their own pip tools.

————————————————

    • 1. Check whether pip is installed
  • Terminal input: pip --version [python2 version command]

pip3 --version [python3 version command]

The following figure shows the status of successfully installed pip

 The following page appears, indicating that pip3 is not installed

2. Install pip3

Terminal input command:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py # Download and install the script

sudo python3 get-pip.py # run the installation script

Note: pip is linked to which version of Python you run the install script with. Generally, pip corresponds to Python 2.7, and pip3 corresponds to Python 3.x.

3. Common commands of pip3

show version and path pip3 --version

upgrade pip pip3 install -U pip

Installation package

pip install SomePackage # latest version

pip install SomePackage==1.0.4 # specify the version

pip install 'SomePackage>=1.0.4' # minimum version

Guess you like

Origin blog.csdn.net/qq_42954795/article/details/127280158