pip install 命令报错Temporary failure in name resolution

在Linux环境下使用pip install时遇到'Temporary failure in name resolution'错误。通过编辑/etc/resolv.conf文件,添加DNS解析配置,可以解决此问题。只需执行sudo vi /etc/resolv.conf,然后添加相关DNS服务器信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

pip install 命令报如下错误

Collecting labelme
  Using cached https://files.pythonhosted.org/packages/79/a4/01b9500bc62e6930157a37f2fb2522c1797ffa0ad70684a805ec9fa0df6e/labelme-4.5.7.tar.gz
Collecting imgviz>=0.11.0 (from labelme)
  Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fef0dd6e4e0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /packages/e9/71/a57677fcac28dce37869d1798ce1ca3bde44e9eabe016eed928187b888dc/imgviz-1.2.6.tar.gz
  Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fef0dd6e7f0>: Failed to establish a new connection: [Errno -3] Temporary fa
kaggle中WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7a356dc338d0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution&#39;)&#39;: /simple/keras-bert/ WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7a356dc33410>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution&#39;)&#39;: /simple/keras-bert/ WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7a356dc33290>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution&#39;)&#39;: /simple/keras-bert/ WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7a356dc33590>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution&#39;)&#39;: /simple/keras-bert/ WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by &#39;NewConnectionError(&#39;<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7a356dc354d0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution&#39;)&#39;: /simple/keras-bert/ ERROR: Could not find a version that satisfies the requirement keras_bert (from versions: none) ERROR: No matching distribution found for keras_bert
05-28
### 解决 `pip install fire` 报错问题 当遇到 `pip install fire` 命令执行失败的情况时,可以从以下几个方面排查并解决问题: #### 1. 更新 pip 和 setuptools 工具 确保使用的 pip 版本是最新的,旧版本可能会引发兼容性问题。可以尝试更新 pip 和 setuptools 来解决潜在的问题。 ```bash python -m pip install --upgrade pip setuptools wheel ``` #### 2. 安装缺失依赖项 如果报错提示缺少某些 C 库或其他依赖关系,则需先安装这些必要的组件。对于 Python 的扩展包来说,通常需要编译环境支持。例如,在 Windows 上可能需要 Visual Studio 或者 MinGW 等工具链来构建二进制文件[^4]。 #### 3. 使用预编译的 whl 文件 有时直接通过源码安装会因为本地缺乏合适的编译器而出现问题。此时可以选择寻找官方发布的适用于当前平台架构(如 win_amd64)的 .whl 轮子文件来进行离线安装。访问 PyPI 页面查找是否有适合系统的轮子文件可用,并按照如下方式安装: ```bash pip install some-package.whl ``` #### 4. 设置正确的网络配置 如果是由于代理设置不当引起的连接超时或重试错误,应该确认公司的防火墙策略以及是否正确设置了 HTTP/HTTPS_PROXY 环境变量[^3]。可以通过命令行临时指定代理服务器地址来测试效果: ```bash set HTTPS_PROXY=http://your_proxy_address:port pip install fire ``` 或者将上述指令加入到批处理脚本中长期生效。 #### 5. 清理缓存数据 频繁的操作可能导致 pip 缓存损坏,进而影响后续操作的成功率。清理 pip 的缓存目录有助于排除此类干扰因素。 ```bash pip cache purge ``` 以上措施能够帮助诊断和修复大部分由不同原因引起 `pip install fire` 失败的情形。具体采取哪种方案取决于实际发生的异常信息内容。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值