conda安装镜像源相关命令
时间: 2025-04-16 08:48:15 浏览: 36
### 如何配置和使用 Conda 安装镜像源
为了提高下载速度并减少网络延迟,在中国地区可以将 Anaconda 的默认仓库更换为国内的镜像站点。通过修改 `~/.condarc` 文件或使用命令行工具来完成这一操作。
#### 使用命令行方式设置镜像源
可以通过简单的命令行指令快速切换到清华 TUNA 或者中科大USTC等常用镜像站:
```bash
# 设置为清华大学镜像源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes [^1]
# 如果还需要其他频道,比如 main 和 r,则继续添加如下:
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/
```
对于已经安装过的包,默认情况下会保留原有的下载链接;如果希望每次都能看到具体的下载地址,可执行上述提到的最后一句命令。
#### 手动编辑 `.condarc` 文件
另一种方法是直接编辑位于用户主目录下的隐藏文件`.condarc`,该文件用于存储Conda的各种配置参数。打开此文件后可以在其中加入所需的镜像源URL列表:
```yaml
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- defaults
show_channel_urls: true
```
保存更改后的文件即可生效。需要注意的是,当有多个channel时,优先级是从上至下依次降低的,因此建议把常用的或者速度快的放在前面[^2]。
阅读全文
相关推荐


















