Ubuntu20.04安装onnx报错

在Ubuntu20.04上使用pip3安装onnx时遇到网络连接错误,表现为`Network is unreachable`。问题根源在于pip源的连接证书验证失败。通过将pip源切换到阿里云镜像并设置为信任源,成功解决了安装问题。

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

Ubuntu20.04使用pip安装onnx报如下错:

pip3 install onnx
  WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0xffffb54e2310>: Failed to establish a new connection: [Errno 101] Network is unreachable')': /packages/e7/d0/41781c564fc46f886c73917e23aab7088040c0dab6a8158c0260b5f5a8bd/onnx-1.12.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
  WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0xffffb54e2460>: Failed to establish a new connection: [Errno 101] Network is unreachable')': /packages/e7/d0/41781c564fc46f886c73917e23aab7088040c0dab6a8158c0260b5f5a8bd/onnx-1.12.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
  WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0xffffb54e2790>: Failed to establish a new connection: [Errno 101] Network is unreachable')': /packages/e7/d0/41781c564fc46f886c73917e23aab7088040c0dab6a8158c0260b5f5a8bd/onnx-1.12.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
  WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0xffffb54e27f0>: Failed to establish a new connection: [Errno 101] Network is unreachable')': /packages/e7/d0/41781c564fc46f886c73917e23aab7088040c0dab6a8158c0260b5f5a8bd/onnx-1.12.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
  WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0xffffb54e2940>: Failed to establish a new connection: [Errno 101] Network is unreachable')': /packages/e7/d0/41781c564fc46f886c73917e23aab7088040c0dab6a8158c0260b5f5a8bd/onnx-1.12.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
ERROR: Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/e7/d0/41781c564fc46f886c73917e23aab7088040c0dab6a8158c0260b5f5a8bd/onnx-1.12.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0xffffb54e2ac0>: Failed to establish a new connection: [Errno 101] Network is unreachable'))

解决方法:

 猜测和pip源链接有关,出现该错误信息是因为pip源连接证书验证失败,将pip源调整为国内的源并信任,改为如下后,可以正常安装。

sudo pip3 install onnx -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com

参考:

python WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None))_Coco_淳的博客-优快云博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值