Home > Backend Development > Python Tutorial > A simple guide to installing pip on Windows

A simple guide to installing pip on Windows

PHPz
Release: 2024-01-17 08:55:06
Original
1895 people have browsed it

A simple guide to installing pip on Windows

Simple and easy-to-understand guide to installing pip on Windows, specific code examples are required

When developing using Python, we may often need to install various third-party libraries to extend the functionality of Python. And pip is a very convenient Python package management tool that can help us quickly install and upgrade various Python packages. This article will introduce you in detail how to install pip under Windows system and provide specific code examples.

Step one: Download get-pip.py

First, we need to download the latest version of the pip installation file. We can get it by visiting the official website https://pip.pypa.io/en/stable/installing/. Find "get-pip.py" on the page, right-click the link and select "Save As" to save it locally.

Step 2: Install pip

Next, we need to use the "get-pip.py" file to install pip. We can install it through the following steps:

  1. Open the command prompt (click the "Start" button, search for "command prompt" and open it).
  2. Use the cd command to switch to the directory where the get-pip.py file is saved. For example, if you save it in the root directory of C drive, you can use the command cd C: to switch to the root directory of C drive.
  3. Run the following command to install pip:
python get-pip.py
Copy after login

This will automatically download and install the latest version of pip.

Step 3: Verify whether pip installation is successful

We can use the following command to verify whether pip is installed successfully:

pip --version
Copy after login

If the installation is successful, pip will be printed out version number.

Step 4: Use pip to install Python packages

Now that we have successfully installed pip, we can use it to install various Python packages. Here are some practical examples:

  1. Install numpy package:
pip install numpy
Copy after login
  1. Install Django package:
pip install Django
Copy after login
  1. Upgrade Installed packages:
pip install --upgrade numpy
Copy after login

Step 5: Configure pip source

By default, pip will download Python packages from official sources. If your access to the official source in China is slow, you can perform the following configuration to replace it with a domestic mirror source. This speeds up package downloads.

  1. Create a folder named pip and create a file named pip.ini under the folder. The path is: C:Users current user name pippip.ini.
  2. Edit the pip.ini file and fill in the following content in the file:
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/

[install]
trusted-host = mirrors.aliyun.com
Copy after login
  1. After saving the file, use pip again to install the package, it will be from the domestic mirror source to download.

The above is a simple guide to install pip under Windows system. I hope that the introduction in this article can help you successfully install pip and install and upgrade Python packages smoothly.

The above is the detailed content of A simple guide to installing pip on Windows. 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