Changing the pip source#
Original repository
https://pypi.org/simple/
pip mirror sources#
Common sites:
Alibaba Cloud https://mirrors.aliyun.com/pypi/simple/
Tsinghua University https://pypi.tuna.tsinghua.edu.cn/simple/
Nanjing University https://mirror.nju.edu.cn/pypi/web/simple/
Campus Network Union Mirror Station mirrorz-302 intelligent selection https://mirrors.cernet.edu.cn/pypi/web/simple/
Douban http://pypi.douban.com/simple/
Tencent http://mirrors.cloud.tencent.com/pypi/simple/
Huawei https://repo.huaweicloud.com/repository/pypi/simple/
Campus Network Union Mirror Station:
- PyPI software repository mirror usage help https://help.mirrors.cernet.edu.cn/pypi/
The synchronization of the union mirror station and the university mirror may be slower. If you need the latest pypi library, you can use the original repository https://pypi.org/simple
Changing the source#
1. Temporary source change#
pip install -i https://mirrors.aliyun.com/pypi/simple/ package_name
If the project contains a requirement.txt file
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
pip install -r requirements.txt -i https://mirror.nju.edu.cn/pypi/web/simple/
2. Permanent source change#
Linux environment source change (system pip)#
Create or open ~/.pip/pip.conf
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host = https://mirrors.aliyun.com
Windows system#
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/
References:
https://zhuanlan.zhihu.com/p/551940762
https://blog.csdn.net/weixin_44621343/article/details/116459859