conda和pip换源

有时候下载包实在太慢,不得不考虑换源。

无论是conda还是pip,关于源的配置文件在天然状况下都是不存在的,需要手动创建或使用命令创建。

下面的操作均假设anaconda的路径已经被加入环境变量。即下面几条路径,但请注意你的路径根目录与我可能不同。

D:\Program\anaconda3
D:\Program\anaconda3\Library\mingw-w64\bin
D:\Program\anaconda3\Library\usr\bin
D:\Program\anaconda3\Library\bin
D:\Program\anaconda3\Scripts

conda换源

可用的源

清华:https://mirror.tuna.tsinghua.edu.cn/help/anaconda/

上海交大:https://mirrors.sjtug.sjtu.edu.cn/#/ (搜anaconda,点击查看帮助)

windows系统

配置文件为C:\Users\username\.condarc,但是我们前面讲了该文件天然状况下是不存在的,所以需要手动创建,如果无法手动创建这个文件(有的系统里好像没法创建以点开头的文件),可以打开cmd,输入conda config,那么该文件就会被创建出来。

以清华源为例,登陆上面清华源的网站,上面地址有教我们怎么修改.condarc中的内容,但配置文件里也不必写那么多,一般下面内容即可:

channels:
  - defaults
show_channel_urls: true
channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

最后一行是专门用来安装pytorch的,因为pytorch自己的源经常下不动,如果不需要安装pytorch可以删除最后一行。

linux系统(ubuntu)

配置文件地址是/home/user/.condarc,修改方式同windows系统。

pip换源

可用的源

清华:https://pypi.tuna.tsinghua.edu.cn/simple

阿里云:http://mirrors.aliyun.com/pypi/simple/

中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

豆瓣:http://pypi.douban.com/simple/

windows系统

配置文件为C:\Users\username\pip\pip.ini,pip目录和其下的pip.ini天然状况下均不存在,需手动创建。

仍以清华源为例,创建好上述文件后,在其中写入如下内容:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

linux系统(ubuntu)

配置文件地址是/home/user/.pip/pip.conf,修改方式同windows系统。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值