简体   繁体   English

由于 OSError 无法安装软件包:[SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败:自签名证书 (_ssl.c:1131)

[英]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:语境:

  • Last time I download a package was about a month ago (I realize of this yesterday)上次我下载一个包是大约一个月前(我昨天意识到这一点)
  • Python version: 3.8.10 / pip version: 21.1.1 Python 版本:3.8.10 / pip 版本:21.1.1
  • Windows 10 / Personal machine and Home network (No company permissions) Windows 10 / 个人机器和家庭网络(无公司权限)
  • This happend at every level: when trying to build a docker, inside a venv and also at System level (outside venv)这发生在每个级别:在尝试构建 docker 时,在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.

相关问题 无法通过 PyPi Mac 安装软件包 - 连接错误:[SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:598) - Failure to install packages via PyPi Mac - connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598) Python ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:748) - Python ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748) ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:852) - ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852) ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:749) - ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749) WordPress Api请求错误:[SSL:CERTIFICATE_VERIFY_FAILED]证书验证失败(_ssl.c:700) - WordPress Api request error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:700) Python 错误“NetworkError: [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:661) - Python error "NetworkError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:661) requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:600) - requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600) 错误:Errno 套接字错误] [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:727) - Error: Errno socket error] [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:727) Easy_install或pip安装错误:[SSL:CERTIFICATE_VERIFY_FAILED]证书验证失败(_ssl.c:579)] - Easy_install or pip install error : [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:579)] Python:[SSL:CERTIFICATE_VERIFY_FAILED]证书验证失败(_ssl.c:646) - Python:[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:646)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM