python
network_error
ai_generated
true
pip._vendor.urllib3.exceptions.ProtocolError:('连接中断:IncompleteRead(已读取 0 字节,预期还需 12345 字节)', IncompleteRead(...))
pip._vendor.urllib3.exceptions.ProtocolError: ('Connection broken: IncompleteRead(0 bytes read, 12345 more expected)', IncompleteRead(0 bytes read, 12345 more expected))
ID: python/pip-connection-broken-incompleteread
80%修复率
83%置信度
0证据数
2024-08-05首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
根因分析
下载连接在传输中途被代理、防火墙、不稳定网络或 CDN 边缘节点切断——pip 收到的字节数少于 Content-Length 承诺的数量。
English
The download connection was cut mid-transfer by a proxy, firewall, flaky network, or a CDN edge — pip received fewer bytes than the Content-Length promised.
解决方案
-
75% 成功率
pip install --timeout 120 --retries 10 <pkg>
-
85% 成功率
pip download --no-deps <pkg> -d ./wheels # or curl -L --retry 5 -o ./wheels/<wheel> https://files.pythonhosted.org/... pip install --no-index --find-links ./wheels <pkg>
-
70% 成功率
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple <pkg> # or your org's mirror
无效尝试
常见但无效的做法:
-
70% 失败
Transient but recurs on large packages; wastes time and bandwidth.
-
90% 失败
The failure is a truncated body, not a certificate problem.
-
80% 失败
Doesn't address proxy/network truncation.