python network_error ai_generated true

警告:连接被 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x...>,'连接到 pypi.org 超时。(连接超时=15)')' 中断后重试(Retry(total=4, ...)):/simple/requests/

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x...>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/requests/

ID: python/pip-index-url-connection-timeout

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

版本兼容性

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

根因分析

到 pypi.org 的网络出口被阻止或较慢(防火墙、VPN、DNS),因此每次连接尝试在 HTTP 握手完成前就超时。

English

Network egress to pypi.org is blocked or slow (firewall, VPN, DNS), so each connection attempt times out before the HTTP handshake completes.

generic

解决方案

  1. 92% 成功率
    export PIP_INDEX_URL=https://mirror.corp.example/simple
    export PIP_TRUSTED_HOST=mirror.corp.example
    python -m pip install requests
  2. 88% 成功率
    export HTTPS_PROXY=http://proxy.corp.example:3128
    export HTTP_PROXY=http://proxy.corp.example:3128
    python -m pip install requests

无效尝试

常见但无效的做法:

  1. 80% 失败

    If the host is unreachable, a longer timeout just makes the failure slower.

  2. 85% 失败

    More retries on a blocked route amplify the delay without success.