国内知名的几个镜像源

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

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

相关推荐
岁月宁静2 小时前
五、《从零手撸 Agent》 — 什么是 Agent:从“会聊天”到“会做事”,差的就是一个循环
python·agent
梯度下降者2 小时前
Python - 函数
python·高阶函数·可调用对象·functools·嵌套作用域
starzy19904 小时前
深入理解Scala隐式参数:上下文流转
开发语言·python·scala
wuyk5555 小时前
Spider-第16讲-线程池与竞态问题
大数据·爬虫·python·elasticsearch·搜索引擎
kyle~11 小时前
FastAPI --- 将业务能力以 API 的形式提供给外部系统
python·fastapi·前后端
aiotto资源分享11 小时前
Python 写 JSON 文件,程序中途退出会留下什么?
java·python·json·jsondecodeerror
2601_9679791212 小时前
简单学Python——NumPy库6——数值计算1——累加和累乘
数值计算·numpy·数组·累加·累乘
梯度下降者12 小时前
Python信号量,条件变量,事件学习
python·条件变量·事件·信号量·线程通信
MSTcheng.13 小时前
【AI应用实战】用 FastAPI + SSE 做一个自己的 AI 聊天网页:流式输出、多轮对话与完整源码
人工智能·python·大模型·fastapi·sse·ai聊天助手
the局外人14 小时前
Python 实战检索优化:BM25、向量与重排
数据库·后端·python