Problem entry · machine-readable · 编码代理与终端

pip 安装超时/下载慢(ReadTimeoutError / WARNING: Retrying ... Read timed out)

本页嵌入 #trove-entity JSON(本条目全量结构化数据);全库数据见 /agent/trove.json。

元数据

idpip-mirror-source收录2026-08-29
问题域编码代理与终端主题分组网络与镜像
适用工具python · 外部工具pip · 外部工具deepcodecode-review-graphlogfireagent-framework

症状

国内网络(校园网/家庭宽带,无代理)跑 pip 时反复超时:

```

pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='download.pytorch.org', port=443): Read timed out.

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError(...)': /simple/pyyaml/

```

特征:报错里的 host 是 `pypi.org`/`files.pythonhosted.org`/`download.pytorch.org` 之一;

装任何包都可能触发,重试几轮后失败;`curl https://pypi.org` 大概率也慢。

官方对这类 issue 的回复往往是「internet connection issue because of China」(sd-webui#11785 原话)。

原因

pip 默认从官方源下载,而官方源对国内网络没有稳定加速(pypi.org / files.pythonhosted.org 无国内 CDN,

直连经常被干扰或丢包);torch 类包走 `download.pytorch.org`,情况更糟。

同一时间不同网络差异很大:校园网、家宽、公司网表现完全不同,所以「换源」比「等重试」可靠。

解法

1. **一次性换源**:`pip install <包> -i https://pypi.tuna.tsinghua.edu.cn/simple`

2. **长期生效**:`pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple`

3. 旧版 pip 补 `--trusted-host`;大包优先换源再装。

验证证据

- 本地实测(2026-08-29,校园网无代理):官方源直连超时复现;清华源换源后安装正常。

- 实测复现日志(2026-08-29)

来源与证据

素材来源:https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/11785

验证证据:Evidence details kept locally (2026-08-29)