当前位置: 首页 > news >正文

pypi 配置国内镜像

pypi 国内镜像目前有:

  • 阿里云(aliyun) - https://mirrors.aliyun.com/pypi/simple/
  • 豆瓣(douban) - https://pypi.douban.com/simple/
  • 清华大学(tuna) - https://pypi.tuna.tsinghua.edu.cnopen in new window
  • 中国科学技术大学 - http://pypi.mirrors.ustc.edu.cn/
临时配置

手动指定源,可以在pip后面跟-i 来指定源,比如用豆瓣的源来安装web.py框架:

pip install -i http://pypi.douban.com/simple/ gevent

pip3 install pip --upgrade -i https://mirrors.aliyun.com/pypi/simple/

pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt

easy_install -i http://pypi.douban.com/simple/ gevent
永久配置

配置文件指定源,linux下修改~/.pip/pip.conf,如果没这文件则创建。

mkdir ~/.pip
cat > ~/.pip/pip.conf << EOF 
[global]
trusted-host=mirrors.aliyun.com
index-url=https://mirrors.aliyun.com/pypi/simple/
EOF

easy_install配置国内源

cat > ~/.pydistutils.cfg << EOF 
[easy_install]
index-url=https://mirrors.aliyun.com/pypi/simple/ 
find-links=https://mirrors.aliyun.com/pypi/simple/
EOF

windows配置

文件夹窗口输入 :

%APPDATA%

新建一个pip文件夹,在pip文件夹里面新建一个配置文件pip.ini

[global]
trusted-host=mirrors.aliyun.com
index-url=https://mirrors.aliyun.com/pypi/simple/

清华源

[global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn
命令行配置

可以直接通过命令行修改 pip 的配置:

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
常见问题与解决方法
配置后安装依赖仍然很慢?

可能是网络问题或依赖库版本冲突。尝试更换其他镜像源,如阿里云镜像:https://mirrors.aliyun.com/pypi/simple

如何恢复默认源?

修改配置文件,将 index-url 改为官方地址:

[global]
index-url = https://pypi.org/simple

或者使用命令行清除配置:

pip config unset global.index-url
遇到 SSL 证书验证失败?

可以通过添加 --trusted-host 参数解决:

pip install 包名 -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn
配置多个镜像源?

可以通过添加 extra-index-url 参数实现:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
extra-index-url = https://mirrors.aliyun.com/pypi/simple/

通过这些方法,开发者可以有效地配置国内 PyPI 镜像源,提高下载和安装 Python 包的速度。

 
http://www.dtcms.com/a/54216.html

相关文章:

  • IDEA Generate POJOs.groovy 踩坑小计 | 生成实体 |groovy报错
  • 数据库安装
  • 测试理论快速入门
  • 记录Linux安装mysql8
  • vue3页面html导出word文档
  • AI视频领域的DeepSeek—阿里万相2.1图生视频
  • [C语言日寄] 字符串操作函数的使用及其拓展
  • C/C++获取结构体成员的偏移量
  • 【CXX】5.2 extern “C++“
  • 4.2 使用说明:手册写作利器VNote的使用
  • 大白话html第十一章
  • I²C总线应用场景及1.8V与3.3V电压选择
  • Nano-GraphRAG复现——只使用Ollama,无需API Key
  • 质量属性场景描述
  • IO基础练习4
  • CogToolBlock和CogIDTool工具
  • ES时序数据库的性能优化
  • C++ Primer 拷贝、赋值与销毁
  • 如何改变怂怂懦弱的气质(2)
  • 记录一次利用条件索引优化接口性能的实践
  • golang并发编程如何学习
  • unsloth-llama3-8b.py 中文备注版
  • 汽车零部件厂如何选择最适合的安灯系统解决方案
  • ESLint 深度解析:原理、规则与插件开发实践
  • C# Unity 面向对象补全计划 之 索引器与迭代器
  • Spring AI 1.0.0-M6 快速开始(一)
  • MySQL批量生成建表语句
  • 解决CentOS 8.5被恶意扫描的问题
  • 美国国家航空航天局(NASA)的PUNCH任务
  • 第十章,防火墙带宽管理