python network_error ai_generated true

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

Also available as: JSON · Markdown · 中文
80%Fix Rate
83%Confidence
0Evidence
2024-08-05First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.8 active — — —
3.9 active — — —
3.10 active — — —
3.11 active — — —
3.12 active — — —

Root Cause

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.

generic

中文

下载连接在传输中途被代理、防火墙、不稳定网络或 CDN 边缘节点切断——pip 收到的字节数少于 Content-Length 承诺的数量。

Workarounds

  1. 75% success
    pip install --timeout 120 --retries 10 <pkg>
  2. 85% success
    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>
  3. 70% success
    pip install -i https://pypi.tuna.tsinghua.edu.cn/simple <pkg>
    # or your org's mirror

Dead Ends

Common approaches that don't work:

  1. 70% fail

    Transient but recurs on large packages; wastes time and bandwidth.

  2. 90% fail

    The failure is a truncated body, not a certificate problem.

  3. 80% fail

    Doesn't address proxy/network truncation.