国内知名的几个镜像源

在国内,有许多常用的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测试安装一个库,看看是否从镜像源下载。

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

相关推荐
会员源码网1 天前
Python中生成器函数与普通函数的区别
python
Java水解1 天前
Python开发从入门到精通:Web框架Django实战
后端·python
曲幽1 天前
FastAPI + PostgreSQL 实战:给应用装上“缓存”和“日志”翅膀
redis·python·elasticsearch·postgresql·logging·fastapi·web·es·fastapi-cache
Lupino1 天前
别再只聊 AI 写代码了:技术负责人要把“变更治理”提到第一优先级
python·docker·容器
Flittly1 天前
【从零手写 ClaudeCode:learn-claude-code 项目实战笔记】(6)Context Compact (上下文压缩)
python·agent
曲幽2 天前
FastAPI + PostgreSQL 实战:从入门到不踩坑,一次讲透
python·sql·postgresql·fastapi·web·postgres·db·asyncpg
用户8356290780512 天前
使用 C# 在 Excel 中创建数据透视表
后端·python
码路飞2 天前
FastMCP 实战:一个 .py 文件,给 Claude Code 装上 3 个超实用工具
python·ai编程·mcp
dev派2 天前
AI Agent 系统中的常用 Workflow 模式(2) Evaluator-Optimizer模式
python·langchain
前端付豪2 天前
AI 数学辅导老师项目构想和初始化
前端·后端·python