Home >Backend Development >Python Tutorial >People learning Python must know: How to quickly install the pip tool

People learning Python must know: How to quickly install the pip tool

WBOY
WBOYOriginal
2024-01-16 08:53:07632browse

People learning Python must know: How to quickly install the pip tool

Must-read for Python enthusiasts: How to quickly install the pip tool

pip is a package management tool for Python, which can easily help us install, uninstall and manage Python. Various third-party libraries. For Python enthusiasts, mastering the use of the pip tool is essential. This article will introduce how to quickly install the pip tool and provide specific code examples.

1. Pip installation under Windows system

  1. Open the browser, visit https://bootstrap.pypa.io/get-pip.py, and download get-pip.py document.
  2. Open the command prompt window and enter the directory where the get-pip.py file is located.
  3. Execute the following command to install pip:

    python get-pip.py
  4. After the installation is completed, run the following command to verify whether the installation is successful:

    pip --version

    If it is correct Output the version information of pip, indicating that the installation is successful.

2. pip installation under macOS system

  1. Open the terminal and execute the following command to install pip:

    curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
    sudo python get-pip.py

    In execution sudo python get-pip.pycommand, you may need to enter the administrator password.

  2. After the installation is completed, run the following command to verify whether the installation is successful:

    pip --version

    If the pip version information can be correctly output, the installation is successful.

3. pip installation under Linux system

For most Linux distributions, pip has been installed with Python. You only need to execute the following command to verify whether it has been installed:

pip --version

If it is not installed, you can install it with the following command:

  • Debian/Ubuntu:

    sudo apt-get install python-pip
  • Fedora:

    sudo dnf install python-pip
  • CentOS:

    sudo yum install epel-release
    sudo yum install python-pip

4. Use domestic mirroring to accelerate pip installation

Due to domestic network reasons, using official sources may cause problems Slow download speed occurs. You can use domestic image sources to speed up pip installation.

  1. Open the terminal (for Windows systems, open the command prompt window), execute the following command to create a folder named pip, and enter the folder:

    mkdir pip
    cd pip
  2. Execute the following command to set the image source to the Alibaba Cloud image:

    pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/

    Or, set the image source to the Tsinghua University image:

    pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/

5. Use pip to install third-party libraries

It is very simple to install third-party libraries using pip. For example, to install a library named requests, you only need to execute the following command:

pip install requests

If you want to specify the version of the installed library, you can use the following command:

pip install requests==2.22.0

6. Use pip to upgrade the third-party library

Use pip to upgrade the installed third-party library It is also very simple, just execute the following command:

pip install --upgrade requests

7. Use pip to uninstall the third-party library

If you want to uninstall the installed third-party library, you can execute the following command:

pip uninstall requests

The above are the detailed steps and code examples on how to quickly install the pip tool. Mastering the use of the pip tool can greatly improve the efficiency of Python development, help us better manage and use third-party libraries, and allow us to focus more on the creation and practice of Python programming.

The above is the detailed content of People learning Python must know: How to quickly install the pip tool. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn