conda镜像源汇总

文章介绍了conda换源的原因,主要是官方源在国外导致下载速度慢或无法访问,以及国内镜像源的不稳定性。提供了多个国内高校的conda镜像源配置步骤,如中科大、清华大学、北京大学等,帮助用户提高软件包下载速度。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


title: conda镜像源汇总
date: 2023-01-12 11:35:38
tags: [conda, 镜像源]


conda换源教程

conda 为什么要换源?有两个原因,一是因为官方源对应的服务器位于国外,下载速度慢,或者根本访问不了,需要添加国内镜像源。二是因为就算添加了国内镜像源,已知的国内镜像源没有一个是绝对稳定的,都有崩溃不能访问的记录,此时需要切换为其他的国内镜像源。

下图是中科大源崩溃不能使用的记录,重试多次后稳定出现 HTTP error:
在这里插入图片描述

1.删除之前配置的镜像源

conda config --remove-key channels

2.新增镜像源(以北京外国语大学源为例)

conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/cloud/bioconda/

3.清除之前本地保存的镜像索引

conda clean -i

清华大学

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
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/cloud/bioconda/

北京大学

conda config --add channels conda config --add channels https://mirrors.pku.edu.cn/anaconda/pkgs/main/
conda config --add channels conda config --add channels https://mirrors.pku.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels conda config --add channels https://mirrors.pku.edu.cn/anaconda/cloud/bioconda/

南京大学

conda config --add channels https://mirror.nju.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirror.nju.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirror.nju.edu.cn/anaconda/cloud/bioconda/

哈尔滨工业大学

conda config --add channels https://mirrors.hit.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.hit.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.hit.edu.cn/anaconda/cloud/bioconda/

西安交通大学

conda config --add channels https://mirrors.xjtu.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.xjtu.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.xjtu.edu.cn/anaconda/cloud/bioconda/

北京交通大学

conda config --add channels https://mirror.bjtu.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirror.bjtu.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirror.bjtu.edu.cn/anaconda/cloud/bioconda/

重庆邮电大学

conda config --add channels https://mirrors.cqupt.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.cqupt.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.cqupt.edu.cn/anaconda/cloud/bioconda/

南方科技大学

conda config --add channels https://mirrors.sustech.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.sustech.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.sustech.edu.cn/anaconda/cloud/bioconda/
<think>好的,我现在需要帮助用户解决如何配置Conda镜像源的问题。用户提到他们想了解配置方法或常用的镜像源地址。首先,我应该回忆一下自己之前学过的关于Conda配置的知识,并结合提供的引用内容来组织答案。 根据用户提供的引用,特别是引用[1]和[4],配置镜像源的主要步骤包括修改.condarc文件,设置channels和custom_channels。另外,引用中提到了清华、阿里云、中科大等常用的镜像源地址。我需要将这些信息整理成步骤,并确保符合用户的要求,比如使用正确的格式和引用标识。 首先,我应该分步骤说明如何通过命令行和手动编辑文件两种方法配置镜像源。然后列出常用的镜像源地址,比如清华、阿里云、中科大的地址。此外,用户可能还关心如何恢复默认设置,所以需要包含恢复默认源的方法。 需要注意的是,用户可能对配置过程中的某些细节不太清楚,比如channels的顺序重要性,或者如何验证配置是否成功。因此,在步骤中加入一些提示,比如使用conda info命令检查配置,或者注意show_channel_urls的设置,可能会有帮助。 另外,引用[4]中提到了custom_channels的部分,特别是conda-forge和pytorch频道的镜像配置,这也是需要包含在配置步骤中的内容。确保用户知道如何为这些常用频道设置镜像,避免下载速度慢的问题。 最后,生成相关问题时要围绕Conda镜像源的配置、其他工具的镜像设置(如pip、homebrew等),以及可能出现的问题,比如配置后无法下载包的情况。这样可以帮助用户进一步解决可能遇到的困难,或者扩展他们的知识。 总结一下,回答的结构应该是:配置方法(命令行和手动编辑)、常用镜像地址、恢复默认源、注意事项,然后相关问题。需要确保所有行内数学表达式正确使用$...$,但在这个问题中可能涉及较少。主要需要正确引用用户提供的引用内容,并在适当的位置添加引用标识,如[^1]、[^4]等。</think>### 如何配置 Conda 镜像源 #### 1. **通过命令行配置镜像源** - 打开终端,执行以下命令生成默认的 `.condarc` 文件(如已存在可跳过): ```bash conda config --set show_channel_urls yes ``` - 添加国内镜像源地址(以清华镜像源为例): ```bash conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2 ``` - 设置 `conda-forge` 和 `pytorch` 等自定义频道的镜像: ```bash conda config --set custom_channels.conda-forge https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud conda config --set custom_channels.pytorch https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud ``` - 验证配置: ```bash conda config --show-sources # 查看当前生效的配置 ``` #### 2. **手动编辑 `.condarc` 文件** - 在用户主目录(如 `~/.condarc`)中直接编辑文件,内容如下: ```yaml channels: - defaults show_channel_urls: true 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 ``` - 保存后执行 `conda clean -i` 清除索引缓存,确保新配置生效[^4]。 --- #### 常用 Conda 镜像源地址 1. **清华大学镜像源** - 地址:`https://mirrors.tuna.tsinghua.edu.cn/anaconda` - 支持频道:`main`, `r`, `msys2`, `conda-forge` 等。 2. **阿里云镜像源** - 地址:`https://mirrors.aliyun.com/anaconda` 3. **中国科学技术大学镜像源** - 地址:`https://mirrors.ustc.edu.cn/anaconda` --- #### 恢复默认镜像源 ```bash conda config --remove-key channels # 删除所有自定义频道 conda config --set custom_channels.conda-forge defaults # 恢复默认频道 ``` --- #### 注意事项 - **频道顺序**:`.condarc` 文件中 `channels` 的顺序决定了 Conda 搜索包的优先级,建议将 `defaults` 放在最后。 - **混合使用镜像源**:部分镜像可能缺少特定包,可临时切换回默认源: ```bash conda install 包名 -c defaults ``` ---
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值