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
发布了1 篇原创文章 · 获赞 1 · 访问量 58

猜你喜欢

转载自blog.csdn.net/qq_39709813/article/details/105597340
今日推荐