国内知名的几个镜像源

在国内,有许多常用的Python库镜像源可以帮助加速库的下载。以下是几个知名的镜像源:

1. 清华大学TUNA协会

2. 阿里云

3. 腾讯云

4. 华中科技大学

5. 中国科学技术大学

6. 豆瓣(Douban)

7. 镜像源配置

为了方便长期使用,你可以将pip的默认源设置为国内镜像源。可以通过编辑或创建~/.pip/pip.conf文件(Windows用户为%USERPROFILE%\pip\pip.ini)来配置。

示例配置文件:
ini 复制代码
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

[install]
trusted-host = pypi.tuna.tsinghua.edu.cn

使用方法

假设你想使用清华大学TUNA协会的镜像源,可以按照以下步骤操作:

  1. 创建配置文件:

    • 在Linux/Mac下,可以使用以下命令创建或编辑pip.conf文件:

      bash 复制代码
      mkdir -p ~/.pip && tee ~/.pip/pip.conf > /dev/null <<EOF
      [global]
      index-url = https://pypi.tuna.tsinghua.edu.cn/simple
      
      [install]
      trusted-host = pypi.tuna.tsinghua.edu.cn
      EOF
    • 在Windows下,可以创建或编辑pip.ini文件:

      bash 复制代码
      mkdir %USERPROFILE%\pip
      echo [global] > %USERPROFILE%\pip\pip.ini
      echo index-url = https://pypi.tuna.tsinghua.edu.cn/simple >> %USERPROFILE%\pip\pip.ini
      echo [install] >> %USERPROFILE%\pip\pip.ini
      echo trusted-host = pypi.tuna.tsinghua.edu.cn >> %USERPROFILE%\pip\pip.ini
  2. 验证配置:

    • 使用pip list检查是否正确配置。
    • 使用pip install numpy测试安装一个库,看看是否从镜像源下载。

通过这些镜像源,你可以显著提升库的下载速度,从而提高开发效率。希望这些信息对你有所帮助!

相关推荐
武天旭7 小时前
AI安全--AI大模型的毒性偏见与安全对齐实践
人工智能·python·深度学习
视觉小萌新8 小时前
AI Class 3 · Chapter 2-3:函数、异常、文件读写+JSON / JSONL 读写(小白版)
人工智能·python·json
小小张说故事9 小时前
Python 的 obj.x 到底按什么顺序找?拆开数据描述符、实例字典和 __getattr__ 那条优先级链
python
用户114818678948410 小时前
水印的实现方式逻辑
前端·python
贾公子10 小时前
从单条内容到账号维度——AIGC 风险评分的工程实现
后端·python
木头左11 小时前
【Python】不点浏览器发博客:逆向 CSDN 创作中心接口做 md-publish 技能
python·自动化·api
Tt有了t12 小时前
设计模式速查
java·python·设计模式
deepseek2312 小时前
Python日志拖慢请求?QueueHandler排队、丢失与退出实测
python·性能优化·logging·后端开发·queuehandler
用户912940468484212 小时前
Codex 从零到能交付(05):第一次改代码:生成一个文件清单脚本
python
Dmz丶12 小时前
前端转 AI 100 天 Day 38:Token 管理与成本优化——别让 API 账单爆炸
python