Skip to content
All Posts

Using a Chinese PyPI Mirror

Instructions for selecting and configuring a Chinese PyPI mirror in pip for temporary or persistent use.

PyPI connections can be slow or blocked in China, which makes pip inconvenient to use. A system-wide proxy is one solution; another is to use a domestic PyPI mirror.

These mirrors were available when this note was written:

The Tsinghua mirror updates every five minutes and is fast, so I recommend it.

Temporary use

Terminal window
sudo pip install <package-name> -i https://pypi.tuna.tsinghua.edu.cn/simple

Default use

Edit ~/.pip/pip.conf with elevated privileges, creating it if necessary, and add:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

Originally published on SegmentFault.