常用国内镜像
清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:https://mirrors.aliyun.com/pypi/simple/
中国科技大学: https://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学:https://pypi.hustunique.com/
山东理工大学:https://pypi.sdutlinux.org/
豆瓣:https://pypi.douban.com/simple/
conda
使用Anaconda安装第三方库的时候,默认下载网站在国外,因此下载速度很慢,可以添加国内镜像源提高下载速度。
1、添加清华镜像源
如遇镜像源网站失效,可以自行前往清华大学开源软件镜像站 | Tsinghua Open Source Mirror获取网址。
# 永久添加清华镜像源-torch下载
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
# 搜索时显示地址
conda config --set show_channel_urls yes
# 临时换源安装
conda install [包名] --channel [源]
2、查看conda通道的配置
显示conda所有通道:
conda config --show channels
如果通道中含有defaults需要删掉,这样在下载时会默认使用清华镜像源:
conda config --remove channels defaults
3、重置通道设置
如果想要删除添加的所有镜像源,重置conda默认源,可以使用以下语句:
conda config --remove-key channels
pip
1、添加源
比如添加清华源 https://pypi.tuna.tsinghua.edu.cn/simple:
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
上述方法如果set了多次,只能保存最后一次set的镜像源。
临时使用镜像安装库,使用 -i
pip install <库名> -i https://pypi.tuna.tsinghua.edu.cn/simple/
2、删除源
pip config unset global.index-url
3、查看现在用的哪个源
pip config list