Python更换pip国内源

目录

国内常用pip源

临时安装换源

永久修改换源

本地下载安装


国内常用pip源

清华大学
URL: https://pypi.tuna.tsinghua.edu.cn/simple
备注:稳定性高,推荐使用。

阿里云
URL: https://mirrors.aliyun.com/pypi/simple
备注:同步频率高,覆盖主流包。

中国科学技术大学(USTC)​
URL: https://pypi.mirrors.ustc.edu.cn/simple
备注:中科大维护,可靠性强。

豆瓣(Douban)​
URL: https://pypi.doubanio.com/simple
备注:速度较快,但偶尔有同步延迟。

华为云
URL: https://repo.huaweicloud.com/repository/pypi/simple
备注:华为云服务,稳定性较好。

腾讯云
URL: https://mirrors.cloud.tencent.com/pypi/simple
备注:适合腾讯云用户。

临时安装换源

在安装包时通过 -i 参数指定镜像源,命令为

pip install 包名 -i https://pypi.tuna.tsinghua.edu.cn/simple

具体为:

清华源

pip install 包名 -i https://pypi.tuna.tsinghua.edu.cn/simple

阿里源

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

中科大源

pip install 包名 -i https://pypi.mirrors.ustc.edu.cn/simple

豆瓣源

pip install 包名 -i https://pypi.doubanio.com/simple --trusted-host pypi.doubanio.com

华为云源

pip install 包名 -i https://repo.huaweicloud.com/repository/pypi/simple

腾讯云源

pip install 包名 -i https://mirrors.cloud.tencent.com/pypi/simple

更改包名为自己需要安装的库名称即可。

永久修改换源

在命令框中输入如下指令,设置永久国内源

pip config set global.index-url <镜像源URL>

具体为:

清华源 

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

阿里源 

pip config set global.index-url https://mirrors.aliyun.com/pypi/simple

中科大源 

pip config set global.index-url https://pypi.mirrors.ustc.edu.cn/simple

豆瓣源 

pip config set global.index-url https://pypi.doubanio.com/simple
pip config set global.trusted-host pypi.doubanio.com  # 解决豆瓣源证书问题

华为云源 

pip config set global.index-url https://repo.huaweicloud.com/repository/pypi/simple

腾讯云源 

pip config set global.index-url https://mirrors.cloud.tencent.com/pypi/simple

设置完成后安装只需要直接输入

pip install 包名

耐心等待下载完成即可。

本地下载安装

有些库下载起来很慢,将其提前下载到本地再通过pip install 安装可以节省很多时间,提高成功率,这里给出一个torch的阿里云镜像下载链接

pytorch-wheels安装包下载_开源镜像站-阿里云pytorch-wheels安装包是阿里云官方提供的开源镜像免费下载服务,每天下载量过亿,阿里巴巴开源镜像站为包含pytorch-wheels安装包的几百个操作系统镜像和依赖包镜像进行免费CDN加速,更新频率高、稳定安全。https://mirrors.aliyun.com/pytorch-wheels/点进去下载需要的版本就可以