conda镜像 。condarc
时间: 2025-03-26 16:31:26 浏览: 39
### 配置 Conda 使用国内镜像源
为了使 Conda 能够更高效地下载包并创建环境,可以配置其使用国内镜像源。这通常通过编辑 `.condarc` 文件来实现。
#### 显示当前配置
如果想要查看现有的通道设置以及确认是否已经存在自定义的镜像源配置:
```bash
conda config --show channels
```
此命令会展示所有已配置的通道列表[^1]。
#### 创建或编辑 .condarc 文件
`.condarc` 文件位于用户的 home 目录下,默认情况下可能不存在该文件。当第一次运行 `conda config` 命令时,它会被自动创建。
要将 Anaconda 的默认仓库替换为中国科学技术大学 (USTC) 或清华大学 TUNA 源作为主要渠道之一,在终端执行如下命令:
对于中国科学技术大学(USTC):
```bash
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
```
对于清华大学(TUNA):
```bash
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
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/main/
conda config --set show_channel_urls yes
```
上述操作不仅添加了新的频道到用户级别的 `.condarc` 中,还启用了显示 URL 功能以便于追踪安装包的具体来源[^2]。
#### 手动编辑 .condarc 文件
也可以手动打开 `.condarc` 文件进行修改。在文本编辑器中找到并更改相应的字段以适应所需的镜像地址。例如:
```yaml
channels:
- defaults
- https://mirrors.ustc.edu.cn/anaconda/pkgs/main
- https://mirrors.ustc.edu.cn/anaconda/pkgs/r
- https://mirrors.ustc.edu.cn/anaconda/pkgs/pro
default_channels:
- https://repo.anaconda.com/pkgs/main
custom_channels:
conda-forge: https://mirrors.ustc.edu.cn/anaconda/cloud
msys2: https://mirrors.ustc.edu.cn/anaconda/cloud
bioconda: https://mirrors.ustc.edu.cn/anaconda/cloud
menpo: https://mirrors.ustc.edu.cn/anaconda/cloud
simpleitk: https://mirrors.ustc.edu.cn/anaconda/cloud
ssl_verify: true
always_yes: false
changeps1: true
auto_update_conda: true
aggressive_update_packages:
- ca-certificates
- certifi
- openssl
channel_priority: flexible
show_channel_urls: true
```
这段 YAML 格式的配置指定了多个来自 USTC 和其他提供者的镜像站点,并设置了若干选项用于优化体验和安全性。
阅读全文
相关推荐




















