[英]Could not install packages due to an OSError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1131)
I'been trying to sovle this problem by reading differents answers in here but none of them turn out to be "the solution",so I would try to breafly explain my situation so you guys can give me a clue.我一直在尝试通过在这里阅读不同的答案来解决这个问题,但结果都不是“解决方案”,所以我会尝试简要解释我的情况,以便你们给我一个线索。 The thing is that when I try to run
pip install <package>
it start with this warnings (just to show you, use as an example fastapi):问题是,当我尝试运行
pip install <package>
时,它会从以下警告开始(只是为了向您展示,以 fastapi 为例):
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 (_ssl.c:1131)'))': /packages/4f/46/226355e82ccb4be82e06269e9a546f16c1d87fbda2286fb5d36a1c31af9e/fastapi-0.75.0-py3-none-any.whl
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 (_ssl.c:1131)'))': /packages/4f/46/226355e82ccb4be82e06269e9a546f16c1d87fbda2286fb5d36a1c31af9e/fastapi-0.75.0-py3-none-any.whl
WARNING: 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 (_ssl.c:1131)'))': /packages/4f/46/226355e82ccb4be82e06269e9a546f16c1d87fbda2286fb5d36a1c31af9e/fastapi-0.75.0-py3-none-any.whl
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 (_ssl.c:1131)'))': /packages/4f/46/226355e82ccb4be82e06269e9a546f16c1d87fbda2286fb5d36a1c31af9e/fastapi-0.75.0-py3-none-any.whl
And it ends with:它以:
ERROR: Could not install packages due to an OSError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/4f/46/226355e82ccb4be82e06269e9a546f16c1d87fbda2286fb5d36a1c31af9e/fastapi-0.75.0-py3-none-any.whl (Caused by SSLError(SSLCertVerificationError(1,'[SSL:CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate(_ssl.c:1131)')))
The first thing that I tried was pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org <package>
, but it only gave me another error.我尝试的第一件事是
pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org <package>
,但它只给了我另一个错误。 So I started to read about SSL Certificates, and when the error says self signed certificates it means that the server that I'm trying to connect, his certificte is self-signed by the server itself or the entity that provides the chain signature is not in the white list of the browser.所以我开始阅读 SSL 证书,当错误显示自签名证书时,这意味着我尝试连接的服务器,他的证书是由服务器本身或提供链签名的实体自签名的在浏览器的白名单中。 And in fact it is so!
事实上就是这样! .
.
But when I use some of the online tools to check the certificates for this site everything seems to be reliable .但是当我使用一些在线工具来检查这个站点的证书时,一切似乎都是可靠的。
Context:语境:
venv
and also at System level (outside venv)venv
内部以及系统级别(venv 外部) So, I don't know where to start really.所以,我真的不知道从哪里开始。 Is my local machine the problem?, is pythonhosted the problem?, Am I mixing things up?, Should I uninstall/re-install Python?
我的本地机器是问题吗?是 pythonhosted 的问题吗?我是不是搞混了?我应该卸载/重新安装 Python 吗?
Below command should solve your problem.下面的命令应该可以解决您的问题。
pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org
<package-name>
Eg:例如:
pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org
pandas
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.