conda和pip下载速度太慢?添加镜像

常用国内镜像

清华: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
  • 3
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值