Home  >  Article  >  Backend Development  >  Detailed explanation of the installation steps of pip under Windows system

Detailed explanation of the installation steps of pip under Windows system

王林
王林Original
2024-01-17 09:00:171588browse

Detailed explanation of the installation steps of pip under Windows system

Detailed explanation of the installation tutorial of Pip under Windows system

We all know that Pip is a package management tool for Python, which facilitates our installation, upgrade, and uninstallation in the Python environment. Third-party libraries. Installing Pip on a Windows system can be a bit tedious, but just follow the steps below and you can get it done easily.

  1. Download the get-pip.py file

First, we need to download the Pip installation file get-pip.py. You can find the latest version of the get-pip.py file on the official website https://pip.pypa.io/en/stable/installing/. Click the link and the file will automatically download.

  1. Set environment variables

Find the path where the get-pip.py file is located and add the path to the system environment variable. Open "My Computer", right-click "Computer", select "Properties", then click "Advanced System Settings", and click "Environment Variables" in the "Advanced" tab. Under "System Variables", find the variable named "Path" and click "Edit". In the pop-up "Edit Environment Variables" window, click "New" and paste the path to the get-pip.py file. Click "OK" to save the settings.

  1. Execute the installation command

Open the command prompt (Win R key, enter "cmd" and press Enter), enter the following command:

python get-pip.py

This will start the installation process and wait for the installation to complete.

  1. Verify the installation results

Enter the following command in the command prompt:

pip --version

If the version information of Pip is successfully displayed, the installation is successful.

  1. Mirror source configuration (optional)

Due to some factors, our access to the default official source may be slow due to network environment and other reasons. In order to improve the installation For the download speed of the package, we can switch to use domestic mirror sources.

Commonly used domestic image sources include Alibaba Cloud, Tsinghua University, Douban, etc. Taking Alibaba Cloud as an example, we need to create a folder named ".pip" in the user directory, and create a " pip.ini" file, its content is as follows:

[global]
index-url = https://mirrors.aliyun.com/pypi/simple/

[install]
trusted-host = mirrors.aliyun.com

Save the file, then reopen the command prompt and enter the following command:

pip --version

If the displayed version information contains the mirror source address, It means that the mirror source is configured successfully.

  1. Use Pip to install third-party libraries

Now that you have successfully installed Pip, you can start using it to install third-party libraries. Enter the following command in the command prompt:

pip install 库名

The "library name" here refers to the name of the third-party library you want to install. For example, if you want to install the NumPy library, just type:

pip install numpy

Wait for the installation to complete and you will be able to use the library.

In addition to installing libraries, Pip also supports some other commonly used commands, such as upgrading libraries, uninstalling libraries, etc. You can use the following commands to perform the corresponding operations:

  • Upgrade library: pip install --upgrade library name
  • Uninstall the library: pip uninstall Library name

Summary:

It does require some steps to install Pip under Windows system, but as long as you follow the above steps, you can easily install Pip and pass Pip conveniently installs and manages third-party libraries. Have a pleasant journey with Python!

The above is the detailed content of Detailed explanation of the installation steps of pip under Windows system. 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