当前位置: 首页 > news >正文

【Conda】配置Conda镜像源

Conda 镜像源配置指南
适用系统:Windows 10(含 Miniconda / Anaconda) & Linux(Ubuntu / CentOS / Debian 等)


1. 为什么要设置镜像源

在中国大陆直接访问 repo.anaconda.com 经常遇到速度慢、连接超时、SSL 错误等问题。把默认源替换为国内镜像,可提升 5-20 倍下载速度。


2. 通用思路

  1. 找到 Conda 的配置文件 .condarc
    • Windows:C:\Users\<用户名>\.condarc
    • Linux:~/.condarc(即 /home/<用户名>/.condarc
  2. 修改或新建 .condarc,写入镜像通道地址。
  3. 清除索引缓存,验证生效。

3. 一键命令行配置(推荐)

打开 终端(Win:Anaconda Prompt / PowerShell;Linux:bash/zsh),复制粘贴即可。

3.1 清华镜像(最常用)

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/free
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/pytorch
conda config --set show_channel_urls yes

如你使用的是 PyTorch、TensorFlow 等特定框架,建议额外添加它们的专用镜像通道,例如:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch

3.2 中科大镜像

conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge
conda config --set show_channel_urls yes

3.3 阿里云镜像

conda config --add channels https://mirrors.aliyun.com/anaconda/pkgs/main
conda config --add channels https://mirrors.aliyun.com/anaconda/pkgs/free
conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/conda-forge
conda config --set show_channel_urls yes

4. 手动编辑 .condarc(备用方案)

如果命令行修改失败,可手动创建/编辑文件,内容如下:

channels:- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch- defaults
show_channel_urls: true

保存后关闭即可。


5. 验证是否成功

conda config --show channels

应看到类似输出:

channels:- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free- ...

6. 清理缓存(确保立即生效)

conda clean -i

7. 恢复默认官方源

conda config --remove-key channels

8. 常见问题 FAQ

问题解决方案
CondaHTTPError / SSLError检查公司/校园网代理,或改用 HTTP 镜像(如 http:// 而非 https://)。
镜像未生效确认 .condarc 路径正确,未存在同名文件冲突。
找不到特定包添加对应 cloud 频道,例如 conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda

9. 附录:常用镜像列表

镜像源主页说明
清华大学https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/最全,更新快
中国科技大学https://mirrors.ustc.edu.cn/anaconda/稳定
北京外国语大学https://mirrors.bfsu.edu.cn/help/anaconda/教育网友好
阿里云https://developer.aliyun.com/mirror/anaconda企业网络友好
http://www.dtcms.com/a/311107.html

相关文章:

  • 【Linux】vim—基操
  • 网易云音乐硬刚腾讯系!起诉SM娱乐滥用市场支配地位
  • 【深度学习②】| DNN篇
  • SmartCLIP:具有识别保证的模块化视觉-语言对齐
  • 基于OAuth2与JWT的微服务API安全实战经验分享
  • Java 垃圾回收机制:自动化内存管理的艺术与科学
  • Python 程序设计讲义(54):Python 的函数——函数概述
  • Linux iptables防火墙操作
  • 一种基于入侵杂草优化算法(IWO)的聚类算法,并与K-Means、高斯混合模型(GMM)进行对比,Matlab
  • 网安-中间件(updating..)
  • HarmonyOS NEXT系列之定制化构建制品
  • HarmonyOS 开发:基于 ArkUI 实现复杂表单验证的最佳实践
  • 电子电气架构 --- 汽车网络安全概述
  • lumerical——布拉格光栅(2)
  • Baumer工业相机堡盟工业相机如何通过YoloV8深度学习模型实现道路车辆事故的检测识别(C#代码UI界面版)
  • LLM隐藏层状态: outputs.hidden_states 是 MLP Residual 还是 Layer Norm
  • 【前端:Html】--1.1.基础语法
  • 在 Elasticsearch 中落地 Learning to Rank(LTR)
  • 修改git commit 提交版本的描述信息
  • 【算法笔记 day four】二分查找
  • realIADD3复现笔记
  • 记录一次ESP32报错Guru Meditation Error: Core 1 panic‘ed (Double exception).
  • 大模型Agent记忆的主流技术与优缺点解析
  • OpenCV HSV与RGB颜色模型的区别
  • 深度学习核心:神经网络-激活函数 - 原理、实现及在医学影像领域的应用
  • 【matlab例程】无迹粒子滤波(UPF)的例程,用于三维环境下多雷达目标跟踪,非线性系统
  • Maven引入其他模块无法调用,出现Unable to find main class
  • [Windows] 微软.Net运行库离线合集包 Microsoft .Net Packages AIO v13.05.25
  • chrome的数据采集插件chat4data的使用
  • Vue 服务端渲染 Nuxt 使用详解