美文网首页
用另一种方式解决WARNING: Retrying (Retry

用另一种方式解决WARNING: Retrying (Retry

作者: 热爱生活H_Li | 来源:发表于2021-02-06 02:03 被阅读0次

完整报错信息如下:

(open-mmlab) hench@hench-Precision-T3610:~$ pip install numpy
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1091)'))': /simple/numpy/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1091)'))': /simple/numpy/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', timeout('_ssl.c:1074: The handshake operation timed out'))': /simple/numpy/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1091)'))': /simple/numpy/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1091)'))': /simple/numpy/
Could not fetch URL https://pypi.org/simple/numpy/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/numpy/ (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1091)'))) - skipping
ERROR: Could not find a version that satisfies the requirement numpy
ERROR: No matching distribution found for numpy
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1091)'))) - skipping
(open-mmlab) hench@hench-Precision-T3610:~$ 

2021.1.18 更新:类似的连接错误也会发生在conda上

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/main/linux-64/current_repodata.json>
Elapsed: -

2021.3.22 更新:再次发生conda下载错误

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/main/linux-64/current_repodata.json>
Elapsed: -

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.

1 情况说明

  1. 我的Linux电脑是用代理proxy进行连接的。在ubuntu的设置-网络 设置过代理,也用代理设置代码给环境变量设置过代理。

这是我export出来的环境变量。

declare -x http_proxy="http://henchli:****@www-proxy.waseda.jp:8080/"
declare -x https_proxy="https://henchli:****@www-proxy.waseda.jp:8080/"

2. 在base环境中可以用pip下载包。

image

2 错误说明

  1. 无法在非base由自己创建的虚拟环境中使用pip下载包。
  2. 把whl文件下载到本地然后用pip本地安装也是不行的。
image

3 解决方法

关于这个问题,网上主要有两种解决思路。我先说不能解决我问题的第一种方法。

1. 各种花式--trusted-host(✘)

我第一次部分解决这个问题就是用了这个网页的方法,用的是douban的镜像。

但是这个方法只能下部分常见的包,比如numpy,scipy之类的。

如果douban没有收录这个包,比如pytorch和tensorflow,那就很麻烦了,比如要自己创建pip.conf然后写入--trusted-host,不同的网页还得改。

因此,我认为这些方法都不能从根本上解决问题。

2. 用export重新设置一次http代理[1] (✔)

export http_proxy="http://www-proxy.waseda.jp:8080"
export https_proxy="http://www-proxy.waseda.jp:8080"
# export http_proxy="http://<proxy.server>:<port>"

2021.1.13更新:碰到好几次过只改了http_proxy还是不行,然后把https_proxy也改了问题就解决了。

image

参考

  1. ^https://stackoverflow.com/questions/19080352/how-to-get-pip-to-work-behind-a-proxy-server

相关文章

网友评论

      本文标题:用另一种方式解决WARNING: Retrying (Retry

      本文链接:https://www.haomeiwen.com/subject/byfgtltx.html