一、问题
在使用Pip install xxx的时候,经常会报这样的一个错误。
(myenv) PS E:\WorkSpace\1v6_code_fs> pip3 install torch
ction has been closed (EOF) (_ssl.c:1131)'))': /simple/torch/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLZeroReturnError(6, 'TLS/SSL conne
ction has been closed (EOF) (_ssl.c:1131)'))': /simple/torch/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLZeroReturnError(6, 'TLS/SSL conne
ction has been closed (EOF) (_ssl.c:1131)'))': /simple/torch/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLZeroReturnError(6, 'TLS/SSL conne
ction has been closed (EOF) (_ssl.c:1131)'))': /simple/torch/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLZeroReturnError(6, 'TLS/SSL conne
ction has been closed (EOF) (_ssl.c:1131)'))': /simple/torch/
Could not fetch URL https://pypi.org/simple/torch/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retri
es exceeded with url: /simple/torch/ (Caused by SSLError(SSLZeroReturnError(6, 'TLS/SSL connection has been closed (EOF) (_ssl.c:1131)'))) - skipping
ERROR: Could not find a version that satisfies the requirement torch (from versions: none)
ERROR: No matching distribution found for torch
二、原因
出现这个问题的原因是什么:
此时需要获得 ssl证书的认证,需要在原来的安装命令后增加:
-i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com (也可换其他源)
三、解决办法
(myenv) PS E:\WorkSpace\1v6_code_fs> pip install scipy -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com
Looking in indexes: http://mirrors.aliyun.com/pypi/simple
Requirement already satisfied: scipy in c:\programdata\anaconda3\envs\myenv\lib\site-packages (1.10.1)
Requirement already satisfied: numpy<1.27.0,>=1.19.5 in c:\programdata\anaconda3\envs\myenv\lib\site-packages (from scipy) (1.24.4)
(myenv) PS E:\WorkSpace\1v6_code_fs> pip install torch -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com
Looking in indexes: http://mirrors.aliyun.com/pypi/simple