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系统。

扫描二维码关注公众号,回复: 15195842 查看本文章

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系统。

猜你喜欢

转载自blog.csdn.net/bby1987/article/details/109233178