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

2025 年最新 conda 和 pip 国内镜像源

在使用 Python 进行科学计算、数据分析等操作时,conda 和 pip 是常用的包管理工具。然而,默认的国外镜像源往往存在下载速度慢、不稳定等问题,严重影响工作效率。为了让大家更顺畅地使用相关工具,本文整理了 2025 年好用的 conda 和 pip 国内镜像源。

一、pip 镜像

(一)设置为默认镜像源

将 pip 国内源设为默认,可一劳永逸地解决下载速度问题。以下是各常用镜像源的设置命令(友情提示:建议大家粘贴为文字后检查一下网址!!!粘贴为文字后检查一下网址!!!粘贴为文字后检查一下网址!!!):

  • 清华 pip 镜像:清华镜像源是国内使用较为广泛且稳定的镜像源之一,覆盖了丰富的 Python 包,更新速度快,能满足大多数用户的需求。
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

  • 阿里 pip 镜像:阿里镜像源依托其强大的云计算资源,在稳定性和下载速度上表现出色,尤其适合对下载速度有较高要求的用户。

pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/

  • 腾讯 pip 镜像:腾讯镜像源结合了自身的网络优势,为用户提供了一个可靠的下载选择,在部分地区可能具有更好的下载速度。

pip config set global.index-url http://mirrors.cloud.tencent.com/pypi/simple

  • 豆瓣 pip 镜像:豆瓣镜像源也是国内较早的一批镜像源,对于一些常见的 Python 包,下载速度较为稳定。

pip config set global.index-url http://pypi.douban.com/simple/

  • 网易 pip 镜像:网易镜像源同样为用户提供了便捷的下载服务,在某些场景下能有效提升下载效率。

pip config set global.index-url https://mirrors.163.com/pypi/simple/

(二)临时使用镜像源

如果只是临时需要从某个镜像源安装包,可以在使用 pip 命令时加上 -i 参数,指定 pip 源,格式为:

pip install xxx -i 镜像源网址

例如,使用网易镜像源安装某个模块:

pip install xxx -i https://mirrors.163.com/pypi/simple/

替换 “xxx” 为你需要安装的模块名称即可。

二、conda 镜像

(一)清华 conda 镜像

清华 conda 镜像源是 conda 用户常用的国内镜像源之一,但由于部分包更新过快难以同步,该镜像源不同步 pytorch-nightly、pytorch-nightly-cpu、ignite-nightly 这三个包。

设置方法
  1. 逐个添加 channels:

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/pytorch/

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

conda config --set show_channel_urls yes

  1. Miniconda 用户还可以直接到清华镜像站下载 Miniconda 安装包,网址为:https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/。
配置文件示例

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

  pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

  deepmodeling: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/

(二)北外 conda 镜像

北外 conda 镜像源为用户提供了另一种选择,其设置步骤如下:

conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/pkgs/free/

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

# Conda Forge(常用的社区维护渠道,包含大量高质量包)

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

# msys2(用于Windows下构建软件,可根据需求选择是否添加)

conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/cloud/msys2/

# bioconda(生物信息学相关包的渠道,可略,按需添加)

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

# menpo(计算机视觉相关包的渠道,可略,按需添加)

conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/cloud/menpo/

# pytorch(PyTorch相关包的渠道)

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

# for legacy win-64(Windows 64位旧版系统相关,可略,按需添加)

conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/cloud/peterjc123/

conda config --set show_channel_urls yes

(三)中科大 conda 镜像

需要注意的是,由于合规性问题,Anaconda 源目前已经无限期停止服务,但中科大仍提供了其他可用的 channels。设置命令如下:

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 --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/

conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/

conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/

conda config --set show_channel_urls yes

(四)阿里 conda 镜像

阿里 conda 镜像源依托其强大的基础设施,为用户提供稳定的下载服务,配置文件如下:

channels:

  - defaults

show_channel_urls: true

default_channels:

  - http://mirrors.aliyun.com/anaconda/pkgs/main

  - http://mirrors.aliyun.com/anaconda/pkgs/r

  - http://mirrors.aliyun.com/anaconda/pkgs/msys2

custom_channels:

  conda-forge: http://mirrors.aliyun.com/anaconda/cloud

  msys2: http://mirrors.aliyun.com/anaconda/cloud

  bioconda: http://mirrors.aliyun.com/anaconda/cloud

  menpo: http://mirrors.aliyun.com/anaconda/cloud

  pytorch: http://mirrors.aliyun.com/anaconda/cloud

  simpleitk: http://mirrors.aliyun.com/anaconda/cloud

(五)conda 常用操作命令

为了方便大家更好地使用 conda,以下按照使用场景分类整理了常用操作命令:

1. 版本与更新
  • 获取版本号

conda --version 或 conda -V

  • 检查更新当前 conda

conda update conda

2. 虚拟环境管理
  • 查看当前存在哪些虚拟环境

conda env list 或 conda info -e

  • 创建虚拟环境(以创建名为 whatwhale,Python 版本为 3.7 并安装 pip 为例)

conda create --name whatwhale python=3.7 pip

  • 激活虚拟环境(按名称激活)

conda activate whatwhale

  • 退出虚拟环境

conda deactivate

  • 删除虚拟环境(按名称删除)

conda env remove --name whatwhale

  • 删除后验证

conda env list

3. 包管理
  • 查看已安装的包

conda list

  • 查询包

conda search package_name

  • 安装包(直接安装最新版本或指定版本)

conda install package_name

conda install package_name=1.5.0

  • 更新包

conda update package_name

  • 删除包

conda remove package_name

http://www.lqws.cn/news/133327.html

相关文章:

  • JavaWeb简介
  • Python 2.7 退役始末:代码架构缺陷与社区演进路线图
  • Git Github Gitee GitLab
  • Codeforces Round 1027 (Div. 3)
  • [C]C语言日志系统宏技巧解析
  • PageHelper-分页插件
  • Python爬虫:trafilatura 的详细使用(快速提取正文和评论以及结构,转换为 TXT、CSV 和 XML)
  • 平面上的最接近点对
  • 每日算法 -【Swift 算法】三数之和
  • 机器翻译模型笔记
  • 【25-cv-06151】FOLDABLE MIRROR三面折叠镜专利维权案
  • MaskSearch:提升智能体搜索能力的新框架
  • 中级统计师-经济学基础知识-第一章 经济学基础
  • JAVA 集合进阶 01 - 05 双列集合
  • 八:操作系统设备管理之设备驱动程序
  • LangChain4J 使用实践
  • PPTAGENT:让PPT生成更智能
  • Java中的多态
  • Canal
  • A2A MCP 集成
  • 硬路由与软路由
  • GMS地下水数值模拟技术及地下水环评
  • NNLM和word2vec的区别
  • 软件工程专业的本科生应该具备哪些技能
  • 4种常见Python设计爱心创意实现方法
  • ROS中的里程计与IMU的消息类型解读
  • apt-get update提示gpg错误
  • 跨域请求解决方案全解析
  • JAVA-springboot JOSN解析库
  • 基于Web的安全漏洞分析与修复平台设计与实现