ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 配置 conda 镜像环境

配置 conda 镜像环境

Linux操作系统 作者:哈哈哈hh 时间:2021-12-13 10:41:13 0 删除 编辑

镜像下载、域名解析、时间同步请点击  阿里巴巴开源镜像站

环境: conda/4.11.0 CPython/3.8.8 Windows/10
镜像源选用阿里云镜像站anaconda镜像:
参考:https://conda.io/projects/conda/en/latest/user-guide/configuration/use-condarc.html#show-channel-urls-show-channel-urls

使用配置文件修改镜像源

  • 使用 conda info 命令查看 .condarc 配置文件位置(一般为 $env:userprofile/.condarc)

  • 在 PowerShell 中使用 notepad $env:userprofile/.condarc 命令,通过记事本打开 .condarc (若提示文件不存在,则点击创建)

    • CMD 中可以使用 notepad %userprofile%/.condarc 命令

将以下内容填入 .condarc 文件中

channels:
  - defaults
show_channel_urls: true
default_channels:
  - http://mirrors.aliyun.com/anaconda/pkgs/main
  - http://mirrors.aliyun.com/anaconda/pkgs/r
  - http://mirrors.aliyun.com/anaconda/pkgs/msys2
custom_channels:
  conda-forge: http://mirrors.aliyun.com/anaconda/cloud
  msys2: http://mirrors.aliyun.com/anaconda/cloud
  bioconda: http://mirrors.aliyun.com/anaconda/cloud
  menpo: http://mirrors.aliyun.com/anaconda/cloud
  pytorch: http://mirrors.aliyun.com/anaconda/cloud
  simpleitk: http://mirrors.aliyun.com/anaconda/cloud
https://conda.io/projects/conda/en/latest/user-guide/configuration/use-condarc.html#channel-locations-channels

  • channels 的 defaults 会引用 default_channels 中的 URL

  • show_channel_urls 显示下载内容的 URL

使用命令行添加镜像源(失败)

失败原因:custom_channels 的值添加失败;custom_channels 下有仍有键值对,为嵌套关系,但 --add 只能添加一个 key;尝试空格,引号,冒号,括号,斜杠等没有找到方法可以嵌套添加

conda config --set show_channel_urls yes
conda config --add default_channels 
conda config --add default_channels 
conda config --add default_channels 
# conda config --add custom_channels conda-forge: 
# conda config --add custom_channels msys2: 
# conda config --add custom_channels bioconda: 
# conda config --add custom_channels menpo: 
# conda config --add custom_channels pytorch: 
# conda config --add custom_channels simpleitk:
  • 使用 conda config --remove channels  移除相应配置

清理索引缓存

运行 conda clean -i 命令清除索引缓存,确保使用的是镜像站的索引。

原文链接:https://blog.csdn.net/m0_49270962/article/details/121882323


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/70003733/viewspace-2847329/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: Anaconda环境配置
请登录后发表评论 登录
全部评论

注册时间:2021-09-10

  • 博文量
    280
  • 访问量
    250876