conda配置好仍然无法使用

问题概述

从 Conda 23.11 开始,访问官方频道(如 repo.anaconda.com)必须接受 Terms of Service(ToS)协议,否则就会报错:

CondaToSNonInteractiveError: Terms of Service have not been accepted for the following channels.

为什么你用的是 TUNA 清华源却还提示 ToS?

这是因为 Conda 的 TUNA 镜像虽然替换了下载 URL,但 Conda 仍然识别它是 “镜像的 repo.anaconda.com”,所以 依然强制 ToS 接受

⚠ 所以:只换 URL 不足以绕过 ToS 检查!


解决方式(推荐 2 选 1):


方式一:显式接受 ToS(推荐)

添加完 TUNA 镜像后,运行下面两行(一次性):

1
2
conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main
conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r

这会在你的配置里标记「已接受」,之后不会再报错。


方式二:完全移除 Anaconda 官方源,仅使用清华源

编辑 ~/.condarc,把 defaultsrepo.anaconda.com 全部移除,只保留清华:

1
2
3
4
5
6
7
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
default_channels: []
custom_channels: {}

然后运行:

1
conda clean -i

这样 Conda 就不会引用 repo.anaconda.com,自然也不会再要求接受 ToS。


补充建议(脚本自动接受)

你想在脚本中静默接受,可以加入:

1
2
conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main || true
conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r || true