为pip设置国内镜像源

pip设置国内镜像源

在Python中使用pip安装软件包时,通常我们会遇到网络问题,尤其是在中国大陆地区。为了解决这个问题我们可以使用一些国内提供的镜像源。下面以清华大学的镜像源为例进行使用说明。

方法一:临时使用

在命令行中,你可以临时使用清华大学的镜像源来安装软件包。例如,安装requests库:

python 复制代码
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple requests

下面这种方式也是一样的

python 复制代码
pip install requests -i https://pypi.tuna.tsinghua.edu.cn/simple

方法二:永久配置

python 复制代码
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

国内常见的镜像源

  • 清华大学开源软件镜像站 (Tuna)提供的PyPI镜像:https://pypi.tuna.tsinghua.edu.cn/simple
  • 阿里云提供的PyPI镜像:https://mirrors.aliyun.com/pypi/simple
  • 中国科学技术大学 提供的PyPI镜像:https://pypi.mirrors.ustc.edu.cn/simple
  • 腾讯云 提供的PyPI镜像:https://mirrors.cloud.tencent.com/pypi/simple/

参考

  1. 【python镜像设置】pip使用清华镜像源安装
  2. 【Python】Anaconda以及Pip配置清华镜像源
相关推荐
小九九的爸爸15 小时前
前端想要入门Agent开发,要具备哪些Python基础?
python·agent·ai编程
阿耶同学16 小时前
手把手教你用 LangGraph 搭建三层嵌套 Agent 架构
python·程序员
花酒锄作田1 天前
Pydantic校验配置文件
python
hboot1 天前
AI工程师第四课 - 深度学习入门
pytorch·python·神经网络
ZhengEnCi2 天前
P2M-Matplotlib折线图完全指南-从数据可视化到趋势分析的Python绘图利器
python·matlab·数据可视化
ZhengEnCi2 天前
P2L-Matplotlib饼图完全指南-从数据可视化到图表定制的Python绘图利器
python·matlab
曲幽2 天前
你的REST接口还在“过度投喂”数据吗?——FastAPI + GraphQL实战避坑指南
python·fastapi·web·graphql·route·cors·rest·strawberry
用户8358086187912 天前
基于 Self-RAG 与列表级重排序的进阶 RAG 系统设计与实现
python
Warson_L3 天前
Python `Annotated` 与 LangGraph Reducer 学习笔记
python
韩师傅3 天前
海天线算法的前世今生
python·计算机视觉