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

WBOY
Release: 2024-01-16 08:53:07
Original
610 people have browsed it

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
    Copy after login
  4. After the installation is completed, run the following command to verify whether the installation is successful:

    pip --version
    Copy after login
    Copy after login
    Copy after login

    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
    Copy after login

    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
    Copy after login
    Copy after login
    Copy after login

    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
Copy after login
Copy after login
Copy after login

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

  • Debian/Ubuntu:

    sudo apt-get install python-pip
    Copy after login
  • Fedora:

    sudo dnf install python-pip
    Copy after login
  • CentOS:

    sudo yum install epel-release
    sudo yum install python-pip
    Copy after login

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
    Copy after login
  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/
    Copy after login

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

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

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
Copy after login

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

pip install requests==2.22.0
Copy after login

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
Copy after login

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template