简体   繁体   English

我该如何解决 <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)> 在Python中?

[英]How do I fix <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)> in Python?

I have a Django web app that used to work when I had Python installed with Conda. 我有一个Django网络应用程序,当我在Conda上安装Python时可以使用。 I have recently uninstalled Conda and installed all my Python packages regularly. 我最近卸载了Conda,并定期安装了所有Python软件包。 I'm trying to run my Django app on a local server and it no longer works. 我正在尝试在本地服务器上运行我的Django应用程序,它不再起作用。 I've discovered the problem is this error: 我发现问题是此错误:

URLError at /submit/
<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)>
Request Method: POST
Request URL:    http://127.0.0.1:8000/submit/
Django Version: 2.1.1
Exception Type: URLError
Exception Value:    
<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)>
Exception Location:  /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py in do_open, line 1320
Python Executable:  /Library/Frameworks/Python.framework/Versions/3.6/bin/python3
Python Version: 3.6.5

I understand there have been some updates regarding certificates with Python 3.6 (see bottom of this article ). 我了解关于Python 3.6的证书已有一些更新(请参阅本文的底部)。 I am hoping to find a simple fix to allow me to continue running this Django app on a local host, and I'm hoping to continue using Python 3.6 without Conda. 我希望找到一个简单的修复程序,以允许我继续在本地主机上运行此Django应用程序,并且希望在不使用Conda的情况下继续使用Python 3.6。 I could try using a virtualenv with a different version of Python installed but I'd like to know if I can still use 3.6. 我可以尝试使用安装了不同版本Python的virtualenv,但我想知道我是否仍然可以使用3.6。 Any insights are appreciated! 任何见解表示赞赏!

The second solution in this post solved it for me. 这篇文章中的第二个解决方案为我解决了。

I tried pip install --upgrade certifi , but this didn't solve it. 我尝试了pip install --upgrade certifi ,但这没有解决。 Running the /Applications/Python 3.6/Install Certificates.command script, which itself ran pip install --upgrade certifi , as well as a few other things, worked! 运行/Applications/Python 3.6/Install Certificates.command脚本(该脚本本身运行了pip install --upgrade certifi )以及其他一些功能,都可以运行!

urllib.error.URLError: <urlopen error [ssl: certificate_verify_failed] certificate verify failed: unable to get local issuer (_ssl.c:1076)< div><div id="text_translate"><p> 我在 python 代码中遇到证书错误,如下在 docker 容器laudio/pyodbc中运行</p><pre> File "/usr/local/lib/python3.7/site-packages/fredapi/fred.py", line 131, in get_series root = self.__fetch_data(url) File "/usr/local/lib/python3.7/site-packages/fredapi/fred.py", line 64, in __fetch_data response = urlopen(url) File "/usr/local/lib/python3.7/urllib/request.py", line 222, in urlopen return opener.open(url, data, timeout) File "/usr/local/lib/python3.7/urllib/request.py", line 525, in open response = self._open(req, data) File "/usr/local/lib/python3.7/urllib/request.py", line 543, in _open '_open', req) File "/usr/local/lib/python3.7/urllib/request.py", line 503, in _call_chain result = func(*args) File "/usr/local/lib/python3.7/urllib/request.py", line 1362, in https_open context=self._context, check_hostname=self._check_hostname) File "/usr/local/lib/python3.7/urllib/request.py", line 1321, in do_open raise URLError(err) urllib.error.URLError: &lt;urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)&gt;</pre><p> 我的证书是最新的</p><pre>root@8a03fe8175b7:/# pip install --upgrade certifi Requirement already up-to-date: certifi in /usr/local/lib/python3.7/site-packages (2020.4.5.1)</pre><p> 我也尝试使用没有帮助的<a href="https://stackoverflow.com/questions/15445981/how-do-i-disable-the-security-certificate-check-in-python-requests" rel="nofollow noreferrer">no_ssl_verification 解决方案</a>。</p><p> 另外,这个文件是空的,这意味着什么吗? 在我的主机上它已满</p><pre>root@2927b5836cfa:/# ls -alt /etc/ssl/certs/ca-certificates.crt -rw-r--r-- 1 root root 0 May 23 20:14 /etc/ssl/certs/ca-certificates.crt</pre><p> 来自容器中 python shell 的更多信息,我不知道这是否有帮助。 但是容器中没有 /export 目录:</p><pre> print(ssl.get_default_verify_paths()) DefaultVerifyPaths(cafile=None, capath=None, openssl_cafile_env='SSL_CERT_FILE', openssl_cafile='/export/home/pb2/build/sb_0-35870562-1568195162.53/openssl-1.1.1d-el6-x86-64bit/ssl/cert.pem', openssl_capath_env='SSL_CERT_DIR', openssl_capath='/export/home/pb2/build/sb_0-35870562-1568195162.53/openssl-1.1.1d-el6-x86-64bit/ssl/certs')</pre><p> 你能给我一些想法来解决这个问题吗?</p></div></urlopen> - urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)

urllib.error.URLError: <urlopen error [ssl: certificate_verify_failed] certificate verify failed: unable to get local issuer (_ssl.c:1108)< div><div id="text_translate"><pre> import yfinance as yf</pre><p> msft = yf.Ticker("MSFT")</p><p> 微软信息</p><p>我尝试打印 msft.info 并得到 'urllib.error.URLError: &lt;urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败:无法获取本地颁发者证书 (_ssl.c:1108)' 错误。 我尝试重新运行 Install Certificates.command 和 Update Sheet.command,但显然它不起作用。 同样在我重新运行它们之后,我得到了这个消息: 由于 EnvironmentError 无法安装软件包:[Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/证书 2021.5.30.dist 信息。</p><p> 任何建议我该如何解决?</p></div></urlopen> - urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 urlopen 错误 [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败:无法获取本地颁发者证书 (_ssl.c:1056) - urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056) Python 错误“NetworkError: [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:661) - Python error "NetworkError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:661) <urlopen error [ssl: certificate_verify_failed] certificate verify failed: unable to get local issuer (_ssl.c:1108)></urlopen> - <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)> Python ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:748) - Python ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748) 错误:Errno 套接字错误] [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:727) - Error: Errno socket error] [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:727) Python:[SSL:CERTIFICATE_VERIFY_FAILED]证书验证失败(_ssl.c:646) - Python:[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:646) WordPress Api请求错误:[SSL:CERTIFICATE_VERIFY_FAILED]证书验证失败(_ssl.c:700) - WordPress Api request error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:700) 如何查找根源:urllib2.URLError: - How to find root-cause of: urllib2.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)? urllib.error.URLError: <urlopen error [ssl: certificate_verify_failed] certificate verify failed: unable to get local issuer (_ssl.c:1076)< div><div id="text_translate"><p> 我在 python 代码中遇到证书错误,如下在 docker 容器laudio/pyodbc中运行</p><pre> File "/usr/local/lib/python3.7/site-packages/fredapi/fred.py", line 131, in get_series root = self.__fetch_data(url) File "/usr/local/lib/python3.7/site-packages/fredapi/fred.py", line 64, in __fetch_data response = urlopen(url) File "/usr/local/lib/python3.7/urllib/request.py", line 222, in urlopen return opener.open(url, data, timeout) File "/usr/local/lib/python3.7/urllib/request.py", line 525, in open response = self._open(req, data) File "/usr/local/lib/python3.7/urllib/request.py", line 543, in _open '_open', req) File "/usr/local/lib/python3.7/urllib/request.py", line 503, in _call_chain result = func(*args) File "/usr/local/lib/python3.7/urllib/request.py", line 1362, in https_open context=self._context, check_hostname=self._check_hostname) File "/usr/local/lib/python3.7/urllib/request.py", line 1321, in do_open raise URLError(err) urllib.error.URLError: &lt;urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)&gt;</pre><p> 我的证书是最新的</p><pre>root@8a03fe8175b7:/# pip install --upgrade certifi Requirement already up-to-date: certifi in /usr/local/lib/python3.7/site-packages (2020.4.5.1)</pre><p> 我也尝试使用没有帮助的<a href="https://stackoverflow.com/questions/15445981/how-do-i-disable-the-security-certificate-check-in-python-requests" rel="nofollow noreferrer">no_ssl_verification 解决方案</a>。</p><p> 另外,这个文件是空的,这意味着什么吗? 在我的主机上它已满</p><pre>root@2927b5836cfa:/# ls -alt /etc/ssl/certs/ca-certificates.crt -rw-r--r-- 1 root root 0 May 23 20:14 /etc/ssl/certs/ca-certificates.crt</pre><p> 来自容器中 python shell 的更多信息,我不知道这是否有帮助。 但是容器中没有 /export 目录:</p><pre> print(ssl.get_default_verify_paths()) DefaultVerifyPaths(cafile=None, capath=None, openssl_cafile_env='SSL_CERT_FILE', openssl_cafile='/export/home/pb2/build/sb_0-35870562-1568195162.53/openssl-1.1.1d-el6-x86-64bit/ssl/cert.pem', openssl_capath_env='SSL_CERT_DIR', openssl_capath='/export/home/pb2/build/sb_0-35870562-1568195162.53/openssl-1.1.1d-el6-x86-64bit/ssl/certs')</pre><p> 你能给我一些想法来解决这个问题吗?</p></div></urlopen> - urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076) urllib.error.URLError: <urlopen error [ssl: certificate_verify_failed] certificate verify failed: unable to get local issuer (_ssl.c:1108)< div><div id="text_translate"><pre> import yfinance as yf</pre><p> msft = yf.Ticker("MSFT")</p><p> 微软信息</p><p>我尝试打印 msft.info 并得到 'urllib.error.URLError: &lt;urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败:无法获取本地颁发者证书 (_ssl.c:1108)' 错误。 我尝试重新运行 Install Certificates.command 和 Update Sheet.command,但显然它不起作用。 同样在我重新运行它们之后,我得到了这个消息: 由于 EnvironmentError 无法安装软件包:[Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/证书 2021.5.30.dist 信息。</p><p> 任何建议我该如何解决?</p></div></urlopen> - urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM