Skip to content
Back to 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.

Copyright notice

Unless otherwise stated, quietin owns the copyright in all articles. All rights reserved. Except as permitted by law or with prior written permission, reproduction or republication, in whole or in part, is prohibited. Permitted quotations must credit the author and link to the original article.