python 在vs代码中安装flask时出现SSL错误

kadbb459  于 2023-02-02  发布在  Python
关注(0)|答案(1)|浏览(717)

我尝试在虚拟环境中安装flask in vs代码,但遇到一些SSL错误。当从虚拟环境中安装flask时,我尝试写入

pip install flask

然后我得到这个错误,

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)'))': /simple/flask/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after 
connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] 
certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)'))': 
/simple/flask/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after 
connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] 
certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)'))': 
/simple/flask/
: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after 
connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] 
certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)'))': 
/simple/flask/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after 
connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] 
certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)'))': 
/simple/flask/
Could not fetch URL https://pypi.org/simple/flask/: There was a problem confirming the ssl 
certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: 
/simple/flask/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: 
CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate 
chain (_ssl.c:997)'))) - skipping
ERROR: Could not find a version that satisfies the requirement flask (from versions: none)
ERROR: No matching distribution found for flask
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(SSLCertVerificationError(1, '[SSL: 
CERTIFICATE_VERIFY_FAILED] certificate verify failed: self 
signed certificate in certificate chain (_ssl.c:997)'))) - skipping

怎么解决这个问题。
当我尝试安装虚拟环境时,我在我的anaconda提示符和anaconda导航器中也遇到了相同类型的SSL错误,现在我意识到由于这个SSL认证错误,我甚至无法更新任何包。
anaconda提示符中的SSL错误如下所示,

CondaSSLError: Encountered an SSL error. Most likely a certificate verification issue.

Exception: HTTPSConnectionPool(host='repo.anaconda.com', port=443): Max retries exceeded with 
url: /pkgs/main/win-64/current_repodata.json 
(Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate 
verify failed: self signed certificate in certificate chain (_ssl.c:997)')))

我确实需要帮助,因为它显然阻碍了我的学习之旅。

q8l4jmvw

q8l4jmvw1#

这似乎是因为ssl_verify阻止了它。您可以尝试运行以下命令并将其更改为false(此方法包含风险):

conda config --set ssl_verify False

另一个安全的方法是让conda知道您的SSL证书的位置:

conda config --set ssl_verify <pathToYourFile>.crt

您可以阅读this issue了解更多详情。

相关问题