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/pkgs/free/conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/conda config --append channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/fastai/conda config --append channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/conda config --append channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
时间: 2025-04-04 12:03:10 浏览: 80
### 配置 Conda 添加清华大学镜像源
为了通过 `conda config` 命令添加清华大学镜像的多个 channels,可以按照以下方法操作:
#### 1. 清华大学镜像的主要地址
清华大学提供了 Anaconda 的镜像服务,其主要地址为 `https://mirrors.tuna.tsinghua.edu.cn/anaconda/`。基于此地址,可以通过 `conda config` 命令依次添加所需的 channels。
以下是具体的操作命令列表:
```bash
# 添加 pkgs/free channel
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
# 添加 pkgs/main channel
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
# 添加 conda-forge channel
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
# 添加 fastai channel
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/fastai/
# 添加 pytorch channel
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
# 添加 bioconda channel
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
```
以上每条命令都会向用户的 `.condarc` 文件中追加对应的 channel 地址[^1]。
#### 2. 设置显示 channel URL
为了让每次安装包时都能看到具体的 source address,建议设置如下选项:
```bash
conda config --set show_channel_urls yes
```
这一步会确保在后续使用过程中能够清晰了解所使用的镜像源来自哪个 channel。
#### 3. 创建并激活新的 Conda 环境(可选)
如果需要在一个全新的环境中测试这些配置效果,也可以先创建一个新的环境再执行上述步骤:
```bash
# 创建名为 test_env 的新环境,并指定 Python 版本
conda create -n test_env python=3.8
# 激活该环境
conda activate test_env
```
随后即可在此环境下完成 mirror 的配置工作[^3]。
#### 注意事项
- 如果 Miniconda 或 Anaconda 安装路径不在默认位置,则可能还需要手动调整 PATH 变量以确保命令行工具能找到相关脚本文件[^4]。
- 上述所有更改均会影响全局范围内的 Conda 行为;若仅希望针对特定项目应用特殊 settings,则应考虑利用独立 environments 来隔离影响。
阅读全文
相关推荐



















