conda 配置源

无论是Anaconda vs Miniconda vs Miniforge 中的哪个,只要使用conda就涉及源,换源的目的是为了加速包的获取

修改配置文件

通过修改用户目录下的 .condarc 文件来使用

不同系统下的 .condarc 目录如下:

  • Linux: ${HOME}/.condarc
  • macOS: ${HOME}/.condarc
  • Windows: C:\Users\<YourUserName>\.condarc

注:

  • Windows 用户无法直接创建名为.condarc 的文件,可先执行 conda config --set show_channel_urls yes 生成该文件之后再修改。
  • 由于更新过快难以同步,TUNA 等镜像站不同步pytorch-nightly , pytorch-nightly-cpu , ignite-nightly 这三个包。
  • 如果您正在从某一镜像源切换到另一镜像源,请检查镜像源是否同步了您所需要的 repo,以及该 repo 是否支持您使用的平台 (e.g. linux-64)。
  • 为了保证以下配置在所有镜像站可用,配置中只加入了少量必须的第三方源,

清华大学开源软件镜像站

复制代码
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

即可添加 Anaconda Python 免费仓库。

使用下列命令清除索引缓存,并安装常用包测试一下。

复制代码
conda clean -i
conda create -n myenv numpy

使用命令

查看源

复制代码
conda config --show-sources


###
C:\Users\johnny>conda config --show-sources
==> C:\johnny\soft\miniforge3\.condarc <==
channels:
  - conda-forge

==> C:\Users\johnny\.condarc <==
channels:
  - defaults
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
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
show_channel_urls: True

配置默认的源

复制代码
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

配置第三方源中

复制代码
conda config --set custom_channels.conda-forge https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/

其他镜像站

https://help.mirrors.cernet.edu.cn/anaconda/

https://mirrors.ustc.edu.cn/help/anaconda.html

https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/

相关推荐
积跬步,慕至千里1 天前
解决 Conda 环境在 Jupyter Notebook 中不显示的问题(含重复 Kernel 排查)
windows·jupyter·conda
咕噜咕噜啦啦2 天前
RTX5090配置DGL
pytorch·python·conda·pip
马优晨4 天前
Pip 和 Conda 是什么关系?
conda·pip·pip 和 conda 关系·conda和pip的关系·pip和conda是什么
yuanpan4 天前
Python 与 Conda 编程实战指南:从环境配置到项目运行完整入门
开发语言·python·conda
其实防守也摸鱼5 天前
VS code怎么使用 Conda 安装预编译包
开发语言·网络·c++·vscode·安全·web安全·conda
独隅5 天前
Anaconda、Miniconda 与 Conda 全面对比:核心差异、适用场景与选型指南
conda
独隅5 天前
Anaconda 与 Conda 全面对比:核心差异、适用场景与选型指南
conda
Robot_Nav5 天前
Python 虚拟环境完全指南:venv、virtualenv 与 Conda
python·conda·virtualenv
独隅5 天前
Conda 与 Miniconda 全面对比:核心差异、适用场景与选型指南
conda
学习是种信仰6 天前
复现conda环境及Python 项目路径(PYTHONPATH)问题——基于Ubuntu
python·ubuntu·conda