Conda Channels是Conda程序的镜像源(通道),提供Python程序包镜像加速服务,简称“源”。
一、Default Channel(默认源)
Conda内置镜像源包括Anaconda公司维护的默认源Default Channel和开放源Community Channel。Default Channel默认站点http://repo.anaconda.com或其他站点,统一名称defaults,命令无指定源则默认在defaults查找安装程序。Default Channel源配置default_channels包括Python程序包(pkgs/main)、R包(pkgs/r)和Windows系统Python包适配依赖项(pkgs/msys)。Community Channel由Conda社区成员维护,默认站点http://conda.anaconda.org,涵盖大量开源项目和多版本程序包。内置镜像源默认站点在%USERPROFILE%\.condarc文件中暂无显式配置,熟悉此默认项方便替换站点。Community Channels由channel_alias和custom_channels配置,-c conda-forge选项指定访问https://link.zhihu.com/?target=https%3A//conda.anaconda.org/conda-forge/
conda 常用命令
# 显示镜像源配置
conda config --show
# 仅显示镜像源信息
conda config --show channels
# 删除指定镜像源
biocondaconda config --remove channels bioconda
# 添加指定镜像源
biocondaconda config --add channels bioconda
# 查看Default Channel默认站点
conda config --show default_channels
# 查看Community Channels/channel_alias默认站点
conda config --show channel_alias
二、其他官方镜像源(Channel)
Conda-Forge:最常用的官方镜像源之一,由专业社区成员维护,涵盖程序齐全且更新及时。
Bioconda:基于Conda的生物信息学程序包镜像源,拥有超过8000款生物信息程序及众多版本,具有程序丰富、无需编译、跨平台应用、多语言兼容和社区支持等优势。
Pytorch:PyTorch及其依赖项是由Meta AI开发的开源机器学习库,广泛应用于深度学习领域,具有动态计算图、强大GPU支持、丰富社区支持、自动微分和接近Python使用习惯。
三、标准镜像源配置
通过修改.condarc文件,进行镜像源的配置,此处以清华大学镜像源为例:
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
通过下列命令清除索引缓存,后续安装程序包,将使用新的镜像源
conda clean -i
如果添加第三方源,也可以通过如下命令进行添加:
conda config --set custom_channels.auto https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/
四、代理设置
除镜像源配置外,Conda允许用户登录VPN或使用代理网站加速。
conda config --set proxy_servers.http http://X.x.x.x:xx
conda config --set proxy_servers.https http://X.x.x.x:xx
参考链接:
[1]https://zhuanlan.zhihu.com/p/15672387426
[2]https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/