为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配置清华镜像源
相关推荐
TechEdu202606几秒前
[人工智能]Python12: SciPy 实战指南
人工智能·python·scipy
jack1868932 分钟前
Github Copilot 高效开发实战场景指南
python
AIFQuant32 分钟前
Python A股实时行情API接入:沪深股票数据与WebSocket推送实战
开发语言·python·websocket·金融·a股行情
小小龙学IT33 分钟前
Python Matplotlib 数据可视化库深度解析
python·信息可视化·matplotlib
小小张说故事1 小时前
Python 到底是值传递还是引用传递?一个赋值实验讲透,别再背结论了
python
Maxwin1 小时前
AI 生成的视频怎么局部修改?2026 年分章生成 Manim 代码的最新做法
python·aigc
Java后端的Ai之路1 小时前
07React_Props验证器
人工智能·python·react.js·架构·fastapi
Eider19981 小时前
为Loop Engineering装刹车
python·vibe coding·agent设计模式·loopengineering
kaixin_啊啊1 小时前
【零基础学AI】第 9 章——安装 Python 和开发工具
人工智能·python
雨滴AI自动化测试2 小时前
想让你的自动化测试接入AI,这一步必须要有。
python