【工具】pip和conda添加和删除镜像源

pip

1、添加

pip config set global.index-url xxxxxx
eg:
pip config set global.index-url https://pypi.douban.com/simple/

2、删除

pip config unset global.index-url

3、查看目前正在使用的源

pip config list

题外话:
pip list是查看所有安装的包

conda

1、查看所有源

conda config --show channels

2、添加

conda config --add channels xxx(添加指定的源)
eg:添加豆瓣源
conda config --add channels https://pypi.douban.com/simple/

3、删除所有源

conda config --remove-key channels

4、删除指定的源

conda config --remove-key channels xxx(要删除的指定源)
eg:删除指定的豆瓣源
conda config --remove-key channels https://pypi.douban.com/simple/

conda指令

#安装指定包
conda install xxx(包名)
#移除指定包
conda remove xxx(包名)
#更新指定包
conda update xxx(包名)

小技巧

  • conda config --set show_channel_urls yes作用是从channel中安装包时显示channel的url,这样便可以让我们知道包的安装来源
  • 每个机构(学校、企业)都有可能不止一个镜像源,比如清华大学就有多个镜像源,不同的包可能在不同的镜像源下面(既是是同一家机构),所以当下载一个包失败的时候,可以尝试多换几个镜像源试试,就比如我之前在下载pytorch-gpu版本的时候也是换了很多次镜像,最后使用的下面几个镜像才成功安装,虽然都是清华的镜像但是还是有些不同
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

在这里插入图片描述

  • 7
    点赞
  • 52
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值