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

pip配置阿里云、清华和中科大的镜像

pip 配置文件中,默认情况下只能配置一个主镜像源。如果你想配置多个镜像源,可以使用 extra-index-url 选项来指定额外的镜像源。这些额外的镜像源将在主镜像源不可用时作为备选。

配置多个镜像源

你可以编辑 pip 的配置文件,添加多个镜像源。以下是如何在 pip 的配置文件中配置清华大学、阿里云和中国科学技术大学的镜像源。

方法一:通过 pip 配置命令

你可以使用 pip config 命令来设置额外的镜像源:

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip config set global.extra-index-url https://mirrors.aliyun.com/pypi/simple
pip config set global.extra-index-url https://pypi.mirrors.ustc.edu.cn/simple
方法二:手动编辑 pip 配置文件
  • Linux 和 MacOS

    编辑或创建文件 ~/.pip/pip.conf,添加以下内容:

    [global]
    index-url = https://pypi.tuna.tsinghua.edu.cn/simple
    extra-index-url =
        https://mirrors.aliyun.com/pypi/simple
        https://pypi.mirrors.ustc.edu.cn/simple
    
  • Windows

    编辑或创建文件 %APPDATA%\pip\pip.ini,添加以下内容:

    [global]
    index-url = https://pypi.tuna.tsinghua.edu.cn/simple
    extra-index-url =
        https://mirrors.aliyun.com/pypi/simple
        https://pypi.mirrors.ustc.edu.cn/simple
    

示例

以下是一个完整的示例,展示如何在 Linux 系统上配置多个镜像源:

  1. 创建或编辑 ~/.pip/pip.conf 文件:
mkdir -p ~/.pip
nano ~/.pip/pip.conf
  1. 添加以下内容到 pip.conf 文件中:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
extra-index-url =
    https://mirrors.aliyun.com/pypi/simple
    https://pypi.mirrors.ustc.edu.cn/simple
  1. 保存文件并退出编辑器。

通过这种方式,你可以配置多个镜像源,以提高 pip 的包管理效率。如果主镜像源不可用,pip 将会尝试使用额外的镜像源来下载包。


http://www.kler.cn/a/322512.html

相关文章:

  • vue2实现提取字符串数字并修改数字样式(正则表达式)
  • Diameter协议
  • 【HarmonyOS】横向List高度适配
  • 什么是数据库视图(View)?视图和表有何区别?
  • 从0到1,数字媒体产业基地见证每一个创意的诞生与成长
  • Oracle 数据库安装和配置指南
  • 西电雨课堂刷课工具
  • Matlab/simulink低版本打开高版本
  • 2024/9/27 The Limitations of Deep Learning in Adversarial Settings读后感
  • 如何查看服务器是否有raid阵列卡以及raid类型
  • CVE-2024-1112 Resource Hacker 缓冲区溢出分析
  • 防火墙详解(二)通过网页登录配置华为eNSP中USG6000V1防火墙
  • 基于springBoot校园健康驿站管理平台(源码+教程)
  • 如何将很多个pdf拼接在一起?很多种PDF拼接的方法
  • GloVe(全局词向量嵌入)
  • net core mvc 数据绑定 《1》
  • 串匹配问题的三种算法
  • 卫星导航定位原理学习(三)
  • C语言malloc()函数与calloc()函数的区别
  • Unity 设计模式 之 行为型模式-【命令模式】【责任链模式】