可能解决方案:WARNING:Retrying (Retry(total=4...after connection broken by ‘SSLError...|Could not fetch URL

首先说一下背景:我是在服务器里面跑项目,然后服务器网络的话用的代理proxy

一、下面是我遇到的错误

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /simple/transformers/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /simple/transformers/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /simple/transformers/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /simple/transformers/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /simple/transformers/
Could not fetch URL https://pypi.org/simple/transformers/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/transformers/ (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))) - skipping
ERROR: Could not find a version that satisfies the requirement transformers (from versions: none)
ERROR: No matching distribution found for transformers
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(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))) - skipping

错误来源于命令

pip install PackageName

同样地,错误也出现在conda上。

随后,我惊奇的发现,只有在我所创的环境里下载包才会有这样的问题,在base环境里完全可以下载包,一点问题都没有!!!

遇到的第二个问题:大概就是说,有时候pip不行 要用conda 而且可能还要在后面加-c pytorch
今天就是这样,最后成功的命令是

conda install pytorch=1.10.0 torchvision=0.11.1 cudatoolkit=10.2 -c pytorch

不加**-c pytorch**会报错,用 pip 好像也会报错,挺奇怪的,先记录记录吧。

二、解决思路

关于这个问题,网上主要有两种解决思路。

第一种,也就是使用镜像的方式(✘)

pip install PackageName -i xxx --trusted-host xxx

这类型的解决办法我就没成功解决过这类问题(服务器端)!

第二种,用export重新设置一次http代理 (✔)

下面是我之前用的

export http_proxy="http://xx.xx.xx.xx:xxxx"
export https_proxy="https://xx.xx.xx.xx:xxxx"

下面是我现在用的

export http_proxy="http://xx.xx.xx.xx:xxxx"
export https_proxy="http://xx.xx.xx.xx:xxxx"

注意看区别!
改了export后,问题成功被解决!

参考博文

你可能感兴趣的:(人工智能)