python network_error ai_generated true

错误:异常: 回溯(最近调用最后): ... pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): 读取超时。

ERROR: Exception: Traceback (most recent call last): ... pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.

ID: python/pip-read-timeout-pypi

其他格式: JSON · Markdown 中文 · English
80%修复率
86%置信度
0证据数
2024-06-11首次发现

版本兼容性

版本状态引入弃用备注
3.x active — — —

根因分析

到 files.pythonhosted.org 的网络连接过慢或不稳定,导致 pip 的默认读取超时在 wheel 下载完成前就已耗尽。

English

The network connection to files.pythonhosted.org is too slow or unstable, so pip's default read timeout elapses before a wheel finishes downloading.

generic

解决方案

  1. 90% 成功率
    Run pip install --timeout 120 <pkg>, or set PIP_DEFAULT_TIMEOUT=120 in the environment.
  2. 93% 成功率
    Run pip install -i https://pypi.tuna.tsinghua.edu.cn/simple <pkg> (or another regional mirror).
  3. 88% 成功率
    Use curl -O https://files.pythonhosted.org/.../pkg.whl then pip install ./pkg.whl.

无效尝试

常见但无效的做法:

  1. 70% 失败

    Retries help with transient failures but do not extend the per-read timeout.

  2. 90% 失败

    Cache is unrelated to network timeout.

  3. 95% 失败

    Prereleases do not fix network latency.