Conda国内镜像源及配置过程

 更新时间:2025年08月11日 14:08:36   作者:AI手记叨叨  
文章介绍Conda镜像源使用方法,涵盖临时指定单个/多个源、永久配置及恢复默认设置,同时说明main(官方稳定)、free(逐渐弃用)、conda-forge(社区更新快)等仓库的区别与适用场景

一、Conda国内镜像源

# 清华大学
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/msys2/

# 中国科学技术大学
https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/

# 北京外国语大学
https://mirrors.bfsu.edu.cn/anaconda/pkgs/main/
https://mirrors.bfsu.edu.cn/anaconda/pkgs/free/
https://mirrors.bfsu.edu.cn/anaconda/cloud/conda-forge/

# 南京大学
https://mirror.nju.edu.cn/anaconda/pkgs/main/
https://mirror.nju.edu.cn/anaconda/pkgs/free/

# 华为云
https://mirrors.huaweicloud.com/anaconda/pkgs/main/
https://mirrors.huaweicloud.com/anaconda/pkgs/free/
https://mirrors.huaweicloud.com/anaconda/cloud/conda-forge/

# 腾讯云
https://mirrors.cloud.tencent.com/anaconda/pkgs/main/
https://mirrors.cloud.tencent.com/anaconda/pkgs/free/
https://mirrors.cloud.tencent.com/anaconda/cloud/conda-forge/ 

# 阿里
https://mirrors.aliyun.com/anaconda/pkgs/main/
https://mirrors.aliyun.com/anaconda/pkgs/free/
https://mirrors.aliyun.com/anaconda/cloud/conda-forge/

# 上海交通大学
https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/
https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/free/
https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/conda-forge/

二、Conda临时使用镜像源

指定单个源

  • 直接使用镜像站URL
conda install -c https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/ package_name
  • 或者使用镜像源的别名
conda install -c conda-forge package_name

临时指定多个源

  • Conda按优先级从左到右依次搜索-c参数的源,最后搜索全局配置的源(~/.condarc 中的 channels)
conda install -c https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/conda-forge/ -c defaults package_name

创建环境时临时指定源

conda create -n my_env -c https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/ python=3.9

避免搜索远程源

  • 如果本地已有缓存包,强制使用本地包
conda install --use-local package_name

三、Conda永久配置镜像源

通过conda命令配置

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 --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --set show_channel_urls yes

直接修改.condarc文件

sudo vim ~/.condarc
  • 在用户目录下创建或修改.condarc文件
channels:
  - defaults
show_channel_urls: true
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
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

恢复默认配置

  • 删除 ~/.condarc 文件(简单粗暴)
rm ~/.condarc
  • 或者手动移除 channels
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/

四、仓库说明

main、free和conda-forge是不同的软件包仓库,它们提供不同类型的Python包和环境依赖。

main(主仓库)

来源:

  • 由Anaconda官方维护

内容:

  • 包含Anaconda官方认证的、经过严格测试的稳定版本软件包。
  • 通常是较为成熟的软件,更新频率较低,但稳定性高。

用途:

  • 适合生产环境或需要稳定版本的场景。

free(免费仓库)

来源:

  • Anaconda 官方维护,但已逐渐被弃用。

内容:

  • 早期Anaconda将部分包标记为free(开源免费)和non-free(商业许可)。
  • 现在大多数包已迁移到 main 或 conda-forge,因此 free 仓库中的包较少。

注意:新版本Conda可能不再默认使用free,建议优先使用main或conda-forge。

conda-forge(社区仓库)

来源:

  • 由社区维护(非官方)。

内容:

  • 包含大量最新的开源软件包,更新频繁,版本较新。
  • 许多前沿工具(如机器学习库)会优先发布到 conda-forge。

特点:

  • 包数量远超 main,但稳定性可能略低(未经 Anaconda 官方全面测试)。
  • 与 main 仓库可能存在依赖冲突,建议单独使用或通过环境管理隔离。

用途:

  • 适合开发、测试或需要最新版本的场景。

其他常见库

  • msys2:提供 Windows 系统的工具链(如 GCC、Git)。
  • pytorch:PyTorch 官方维护的仓库。
  • tensorflow:TensorFlow 官方仓库(Google 维护)
  • nvidia:NVIDIA GPU 相关工具(CUDA、cuDNN 等)
  • fastai:Fast.ai 相关的深度学习工具
  • bioconda:生物信息学领域的专用包。
  • ioam:地理空间数据处理(如 geopandas 的早期版本)
  • plotly:Plotly 交互式可视化工具。
  • omnia:分子动力学模拟工具(如 OpenMM)。
  • r:R语言及其科学计算包。

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

相关文章

  • Django查询数据库的性能优化示例代码

    Django查询数据库的性能优化示例代码

    这篇文章主要给大家介绍了关于Django查询数据库性能优化的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧。
    2017-09-09
  • Python图像处理之图像拼接

    Python图像处理之图像拼接

    这篇文章主要介绍了Python图像处理之图像拼接,文中有非常详细的代码示例,对正在学习python图像处理的小伙伴们有非常好的帮助,需要的朋友可以参考下
    2021-04-04
  • 使用Python搭建轻量级静态网页服务器的示例详解

    使用Python搭建轻量级静态网页服务器的示例详解

    这篇文章主要为大家详细介绍了如何使用Python搭建一个轻量级静态网页服务器,零基础也能实现的Web开发初体验,感兴趣的小伙伴可以跟随小编一起学习一下
    2025-07-07
  • 详解Python 中的容器 collections

    详解Python 中的容器 collections

    这篇文章主要介绍了Python 中的容器 collections的相关资料,帮助大家更好的理解和学习python,感兴趣的朋友可以了解下
    2020-08-08
  • python实现贪吃蛇游戏源码

    python实现贪吃蛇游戏源码

    这篇文章主要为大家详细介绍了python实现贪吃蛇游戏,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2020-03-03
  • Python pandas修剪函数clip使用实例探究

    Python pandas修剪函数clip使用实例探究

    在数据处理和分析中,经常面临着需要限制数据范围的情况,而pandas库提供的clip函数就是一个强大的工具,可以方便地对数据进行修剪,本文将深入介绍clip函数的基本用法、常见参数以及实际场景中的应用,以帮助大家充分理解并灵活运用这一功能
    2024-01-01
  • Python 二进制字节流数据的读取操作(bytes与bitstring)

    Python 二进制字节流数据的读取操作(bytes与bitstring)

    本文主要介绍了Python 二进制字节流数据的读取操作(bytes与bitstring),文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2023-03-03
  • python已协程方式处理任务实现过程

    python已协程方式处理任务实现过程

    这篇文章主要介绍了python已协程方式处理任务实现过程,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
    2019-12-12
  • 简单了解python gevent 协程使用及作用

    简单了解python gevent 协程使用及作用

    这篇文章主要介绍了简单了解python gevent 协程,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
    2019-07-07
  • 如何将PySpark导入Python的放实现(2种)

    如何将PySpark导入Python的放实现(2种)

    这篇文章主要介绍了如何将PySpark导入Python的放实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2020-04-04

最新评论