anaconda 安装完成后,国内的网络连接Anaconda的官方源,速度基本为0,大部分时间是连接不上的。国内清华大学有对应的镜像源,可以更改为对应的源,可以通过更换原解决
首先在终端(Terminal)运行下面的命令生成 anaconda的 .condarc配置文件:
conda config
使用下面命令查看 .condarc 中的源
conda config --show channels
windows下
1 添加清华源或阿里源
打开anaconda prompt ,在命令行中直接使用以下命令:
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 --add channels https://mirrors.aliyun.com/anaconda/pkgs/main/
conda config --add channels https://mirrors.aliyun.com/anaconda/pkgs/free/
# 设置搜索时显示通道地址
conda config --set show_channel_urls yes
这几个命令操作其实就是修改了Anaconda用户目录下的.condarc配置文件
当然,也可以直接在客户端里的菜单中打开配置文件修改:
如果源不可用,则会报404错误,需要重新配置
添加镜像的几个注意事项
- 频道没必要重复添加。 比如你添加了清华镜像的bioconda频道之后,北外镜像的bioconda频道就没必要添加了,这俩的内容是一致的,没必要又去让conda搜索一遍。
- 顺序是重要的。 conda在没有指定频道的前提下是从
~/.condarc
文件里从上往下一个频道一个频道去找软件的。所以如果把常用的频道放在最上面有利于更快地找到所需要安装的软件 - 就我目前的使用体验来看,如果做生物信息学相关的话,只需要添加:
- bioconda
- conda-forge
- main
这三个频道就足够了。剩下的一些不常用频道可以在安装软件的时候手动用-c
指定。
现在可用的 conda 镜像站点
接下来就盘点一下国内现在提供anaconda镜像服务的站点吧。顺便把命令也给大家准备好了,直接复制粘贴就可以使用啦。
1. 阿里云
conda config --add channels https://mirrors.aliyun.com/anaconda/pkgs/main/
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/bioconda/
2. 北京外国语大学
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/cloud/bioconda/
3. 清华大学
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
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/bioconda/
4. 北京大学
conda config --add channels conda config --add channels https://mirrors.pku.edu.cn/anaconda/pkgs/main/
conda config --add channels conda config --add channels https://mirrors.pku.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels conda config --add channels https://mirrors.pku.edu.cn/anaconda/cloud/bioconda/
5. 哈尔滨工业大学
conda config --add channels https://mirrors.hit.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.hit.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.hit.edu.cn/anaconda/cloud/bioconda/
Linux下
将以上配置文件写在 ~/.condarc 中
vim ~/.condarc
若安装了 sublime 的也可在终端使用 :subl ~/.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
也可以把 anaconda 仓(https://repo.continuum.io/)的添加进去:
这是在anaconda安装 tensorflow1.4.1 的时候遇到的问题,把这个 anaconda 仓添加进去问题就解决了
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/
- https://repo.continuum.io/pkgs/main
- defaults
show_channel_urls: true
若源不生效,试着把.condarc文件中的 - defaults那行去掉