Fundamentals 8 min read

Boost Python Package Install Speed: How to Add Domestic Pip Mirrors

Learn how to dramatically speed up Python package installations by configuring pip to use domestic mirrors, with step‑by‑step instructions for temporary command‑line usage, permanent Windows and macOS/Linux configuration, and PyCharm graphical setup, plus a handy mirror source list.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
Boost Python Package Install Speed: How to Add Domestic Pip Mirrors

When developing with Python, using pip to install third‑party libraries can be slow in China due to the official PyPI source; manually adding a domestic mirror can significantly improve download speed.

1. Temporary pip mirror (command line)

Install a package with a specific mirror by adding -i or --index-url followed by the mirror URL, e.g.:

pip install package-name -i https://pypi.tuna.tsinghua.edu.cn/simple

Common domestic mirrors:

清华源 : https://pypi.tuna.tsinghua.edu.cn/simple 阿里云 : https://mirrors.aliyun.com/pypi/simple/ 腾讯云 : https://mirrors.cloud.tencent.com/pypi/simple 华为云 : https://repo.huaweicloud.com/repository/pypi/simple 豆瓣源 : https://pypi.doubanio.com/simple/ 中科大源 : https://pypi.mirrors.ustc.edu.cn/simple/ Example using Aliyun to install requests:

pip install requests -i https://mirrors.aliyun.com/pypi/simple/

2. Permanent pip mirror configuration (recommended)

Windows

Create or edit pip.ini in C:\Users\YourUserName\pip.

Insert the following (using Tsinghua as an example):

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn  # add this line if the source uses HTTP

After saving, all future pip install commands will use the configured mirror.

macOS / Linux

Create or edit ~/.pip/pip.conf (create ~/.pip/ if it does not exist).

Insert the following (using Aliyun as an example):

[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyun.com  # add this line if the source uses HTTP

Save the file; subsequent pip install commands will use the mirror.

Verify the configuration with: pip config list If the output shows index-url pointing to your mirror, the setup is successful.

3. PyCharm graphical mirror configuration

Open PyCharm → File → Settings (Windows/Linux) or PyCharm → Preferences (macOS).

Navigate to Project: [YourProject] → Python Interpreter .

Click the gear icon → Manage Repositories... .

In the dialog, add a new repository with the mirror URL (e.g., https://pypi.tuna.tsinghua.edu.cn/simple), optionally remove the default https://pypi.org/simple source.

Confirm with OK .

Now installing packages via PyCharm will use the configured mirror, speeding up downloads.

4. Important notes

Most mirrors support HTTPS (recommended). If a mirror only provides HTTP, add a trusted-host entry in the configuration file.

To revert to the default PyPI source, delete the custom pip.ini / pip.conf file or remove the mirror entry in PyCharm.

5. Summary of methods

pip temporary mirror : Use pip install package -i <mirror-url> for a single installation.

pip permanent mirror : Edit pip.ini (Windows) or pip.conf (macOS/Linux) to set the mirror globally.

PyCharm graphical configuration : Add the mirror in Settings → Python Interpreter → Manage Repositories.

By manually adding mirrors, you can greatly improve Python package download speeds, especially in domestic network environments.

ConfigurationPyCharmpipMirrorpackage-management
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.