Change pip source to Tsinghua mirror

This article is transcoded by SimpRead, original link mirrors.tuna.tsinghua.edu.cn

PyPI Usage Help | Mirror Site Usage Help | Tsinghua University Open Source Software Mirror Site, dedicated to providing high-quality open source software mirrors and Linux mirror sources for domestic and on-campus users to help users access open source software more conveniently.

PyPI Mirror Usage Help

The PyPI mirror syncs every 5 minutes after each successful synchronization.

pip

Temporary Use

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


Note, simple cannot be omitted, and it must be https not http.

Set as Default

Upgrade pip to the latest version (>=10.0.0) before configuring:

python -m pip install --upgrade pip
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple


If your network connection to the default pip source is poor, temporarily use this mirror to upgrade pip:

python -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pip


Configure Multiple Mirror Sources

If you want to configure multiple mirror sources for load balancing, after replacing the index-url, you can continue to add sources as follows:

pip config set global.extra-index-url "<url1> <url2>..."


Please replace the content inside the quotes yourself; source addresses should be separated by spaces.

Available pypi source list (campus network joint mirrors): https://mirrors.cernet.edu.cn/list/pypi

PDM

Set the default mirror via the following command:

pdm config pypi.url https://pypi.tuna.tsinghua.edu.cn/simple


Poetry

Set the default mirror via the following command:

poetry source add --priority=default mirrors https://pypi.tuna.tsinghua.edu.cn/simple/


Set a secondary mirror via the following command:

poetry source add --priority=secondary mirrors https://pypi.tuna.tsinghua.edu.cn/simple/