You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

pip安装pypdf及opencv相关包失败,请求技术支持

问题描述与解决建议

问题场景

执行pip install pypdf时安装失败,报错信息如下:

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f012437ffa0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pypdf/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f01243a0310>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pypdf/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f01243a0670>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pypdf/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f01243a0820>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pypdf/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f01243a09d0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pypdf/
ERROR: Could not find a version that satisfies the requirement pypdf (from versions: none)
ERROR: No matching distribution found for pypdf
WARNING: There was an error checking the latest version of pip.

误以为问题出在opencv上,尝试执行以下命令仍出现相同的"Could not find a version that satisfies the requirement"错误:

pip install opencv-python
pip install python-opencv
pip install opencv-contrib-python

问题根源

报错中的Temporary failure in name resolution是域名解析失败,说明你的机器无法正常连接到PyPI服务器,和opencv没有任何关系。pip找不到包是因为连不上PyPI服务器,根本没获取到包的版本信息,并非包本身不存在。

解决步骤

  • 检查基础网络连接:执行ping pypi.org测试能否访问PyPI服务器,如果不通,排查本地网络是否正常(比如能否正常打开网页),是否有防火墙、网络策略限制。
  • 更换国内PyPI镜像源安装:如果网络正常但访问PyPI慢或失败,直接使用国内镜像源安装,示例命令:
    pip install pypdf -i https://pypi.tuna.tsinghua.edu.cn/simple
    
    安装opencv相关包同理:
    pip install opencv-python -i https://pypi.tuna.tsinghua.edu.cn/simple
    
  • 修复系统DNS配置:如果域名解析持续失败,尝试修改系统DNS服务器为公共DNS,比如8.8.8.8或114.114.114.114。
  • 检查代理设置:如果机器使用代理,确保pip已配置正确的代理参数,示例:
    pip install pypdf --proxy http://代理IP:端口号
    
    若不需要代理,可取消代理环境变量:
    unset HTTP_PROXY
    unset HTTPS_PROXY
    

内容的提问来源于stack exchange,提问作者user20176030

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 19:40:34