Speed Up Python Package Installs: Permanently Switch pip to a Domestic Mirror
This guide explains why changing pip's default source to a Chinese mirror dramatically speeds up package installation, lists popular domestic mirrors, and provides step‑by‑step instructions with screenshots to permanently configure pip on Windows.
Introduction
Python developers often rely on pip to install third‑party packages, but downloading from the official PyPI server can be painfully slow or fail due to network restrictions. Switching to a domestic mirror resolves these issues and provides a stable, fast source.
Why Change the Source?
Default packages are fetched from the overseas PyPI server, which suffers from low bandwidth and occasional blocking. Domestic mirrors host identical content on servers within China, offering much higher download speeds and fewer errors.
Common Domestic Mirrors
Typical mirrors include Tsinghua University, Alibaba Cloud, and others. The tutorial uses the Tsinghua mirror as an example.
Step‑by‑Step Configuration (Windows)
Open the C: drive and locate the Users folder.
Enter your user directory (e.g., C:\Users\YourName).
Create a folder named pip if it does not exist.
Inside the pip folder, create a file called pip.ini.
Paste the following configuration into pip.ini (replace the URL with the desired mirror):
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simpleSave the file and restart the command prompt.
After these steps, installing packages with pip install package_name should reach speeds of around 1.6 MB/s.
Conclusion
By permanently switching pip to a domestic mirror, you can avoid slow downloads and errors, making Python development smoother. For temporary use, you can add the -i option with the mirror URL directly in the install command.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Python Crawling & Data Mining
Life's short, I code in Python. This channel shares Python web crawling, data mining, analysis, processing, visualization, automated testing, DevOps, big data, AI, cloud computing, machine learning tools, resources, news, technical articles, tutorial videos and learning materials. Join us!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
