本文介绍了ssl.SSLError:[SSL:CERTIFICATE_VERIFY_FAILED]证书在OS X上验证失败(_ssl.c:747)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试这段代码.

I am trying this bit of code.

import pandas as pd

fiddy_states=pd.read_html('https://simple.wikipedia.org/wiki/List_of_U.S._states')

print(fiddy_states[0])

我遇到以下错误:

    Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1318, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1400, in connect
    server_hostname=server_hostname)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 401, in wrap_socket
    _context=self, _session=session)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 808, in __init__
    self.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 1061, in do_handshake
    self._sslobj.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 683, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:747)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/avinashmore/Desktop/Desktop pe Desktop/Programming/Python/Pandas/panda4BuidlingDataset.py", line 10, in <module>
    fiddy_states= pd.read_html('https://simple.wikipedia.org/wiki/List_of_U.S._states')
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/io/html.py", line 896, in read_html
    keep_default_na=keep_default_na)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/io/html.py", line 733, in _parse
    raise_with_traceback(retained)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/compat/__init__.py", line 339, in raise_with_traceback
    raise exc.with_traceback(traceback)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:747)>

我尝试了以下操作:卸载并安装证书以及堆栈溢出相关答案中提到的所有其他步骤.仍然无法修复.

I have tried following things:Uninstall and install certifiand all the other steps mentioned in related answers on stack overflow.Still unable to fix it.

请帮助.

推荐答案

我遇到了同样的问题,经过一番搜索,我发现了这个问题 https://bugs.python.org/issue28150

I was having the same problem, and after some searching, i came across thishttps://bugs.python.org/issue28150

有一个命令行可运行脚本("/Applications/Python 3.6/Install Certificates.command"),该脚本使用pip来安装certifi,并在OpenSSL目录中创建一个指向certifi的已安装包位置的符号链接.

There is a command-line-runnable script ("/Applications/Python 3.6/Install Certificates.command") that uses pip to install certifi and creates a symlink in the OpenSSL directory to certifi's installed bundle location.

这对我有用,也许你可以看看.

This worked for me, maybe you can take a look.

这篇关于ssl.SSLError:[SSL:CERTIFICATE_VERIFY_FAILED]证书在OS X上验证失败(_ssl.c:747)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-29 20:41
查看更多