Home >Backend Development >Python Tutorial >pip installation guide under Python3
In Python3, pip is the Python package manager, which can help developers manage the installation, upgrade, and uninstallation of Python packages. However, sometimes when installing Python3, pip is not automatically installed. This article will provide you with a complete guide to installing pip in Python 3 to help Python developers who want to use pip get started more quickly.
1. Install pip on Linux or macOS
For Linux or macOS users, we can use the following command to install pip:
$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py $ sudo python3 get-pip.py
First, we need to install pip from the URL: https://bootstrap.pypa.io/get-pip.py Download get-pip.py, and then run the file using Python3. If the version of Linux or macOS you are using does not support curl, you can use wget to obtain the get-pip.py file:
$ wget https://bootstrap.pypa.io/get-pip.py $ sudo python3 get-pip.py
2. Install pip on Windows
For Windows systems, we The following steps are required to install pip:
C:Python3python.exe get-pip.py
Please replace "C:Python3python.exe" with your Python3 installation directory. For example, if you installed Python3 in the C:Python3 directory, you should run the following command:
C:Python3python.exe get-pip.py
3. Use of pip
If you have successfully installed pip, then next During development, you can use it to install, upgrade, and uninstall Python packages. The following are some common commands for pip:
$ pip3 install 包名
For example:
$ pip3 install requests
$ pip3 install --upgrade 包名
For example:
$ pip3 install --upgrade requests
$ pip3 uninstall 包名
For example:
$ pip3 uninstall requests
$ pip3 freeze
The above command can list all installed Python packages and their version numbers. If you wish to save its output to a file, you can use the following command:
$ pip3 freeze > requirements.txt
Assuming you already have A requirements.txt file, which contains all Python packages and version numbers, you can install these packages through the following commands:
$ pip3 install -r requirements.txt
These commands will bring great convenience when you develop Python3 .
Summary
In this article, we introduce you to a complete guide to installing pip in Python3, and provide some command examples to help use pip. Using pip can make the installation and upgrade of Python packages more convenient, ensuring that developers have the latest tools and libraries for development. I hope that readers can enter the world of Python3 development more easily through the introduction of this article.
The above is the detailed content of pip installation guide under Python3. For more information, please follow other related articles on the PHP Chinese website!