【操作系统(二)】Anaconda换源、pip指定安装源下载

简述:

使用Anaconda在安装程序时,由于源在国外的原因,下载速度慢,时常出现read time out。看了许多的博客,了解到通过换源的方法,将国外源换成国内源,能够使下载速度飞升。

本文介绍了windows与Ubuntu上换源的方法,最后介绍了一个真实有效的快速下载方法

国内安装源主要有:阿里、清华、中科大、豆瓣等。

Windows换源(以清华源为例)

方法一:

打开cmd;

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge 
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
# 设置搜索时显示通道地址
conda config --set show_channel_urls yes

方法二:

打开C盘中的用户文件夹中的用户文件,例如C:\Users\QIAN;

找到最后的.condarc文件,使用记事本打开,把上述代码复制到.condarc中保存,如下图:

可能出现的问题:

即使按照方法一、方法二操作了,依旧没有效果。

解决办法:

打开.condarc,将 - defaults行删除,保存。

 

Ubuntu 换源(以清华源为例)

使用gedit或者vim打开.condarc文件,修改保存即可。例如使用gedit:

gedit ~/.condarc
channels:
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
  - https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - defaults
show_channel_urls: true

 

真实有效的方法:

个人换源后,有时在环境里使用pip安装模块的时候,下载速度并不是很快,通过阅读《pip 更换国内安装源 阿里源 清华源 豆瓣源等等》一文,发现文中介绍的方法在应用中,下载是的确快,很实用。国内pip下载源如下:

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

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

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

华中理工大学:http://pypi.hustunique.com/

山东理工大学:http://pypi.sdutlinux.org/ 

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

在使用pip 安装时,使用 -i 参数,将源导入即可。例如使用清华源安装numpy:

pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值