2017-06-19 19 views
2

這是我在python3代碼:在使用大熊貓得到了錯誤的urlopen錯誤[SSL:CERTIFICATE_VERIFY_FAILED]證書驗證失敗

import pandas as pd 

tables = pd.read_html("https://www.iitp.ac.in/index.php/departments/school-of-basic-sciences/chemistry/people/ug-student-chemistry.html") 

print(tables) 

而且我得到了這個錯誤:

Traceback (most recent call last): 
    File "/usr/local/Cellar/python3/3.6.1/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 "/usr/local/Cellar/python3/3.6.1/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 "/usr/local/Cellar/python3/3.6.1/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 "/usr/local/Cellar/python3/3.6.1/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 "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1026, in _send_output 
    self.send(msg) 
    File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 964, in send 
    self.connect() 
    File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1400, in connect 
    server_hostname=server_hostname) 
    File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 401, in wrap_socket 
    _context=self, _session=session) 
    File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 808, in __init__ 
    self.do_handshake() 
    File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 1061, in do_handshake 
    self._sslobj.do_handshake() 
    File "/usr/local/Cellar/python3/3.6.1/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:749) 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/usr/local/lib/python3.6/site-packages/pandas/io/html.py", line 906, in read_html 
    keep_default_na=keep_default_na) 
    File "/usr/local/lib/python3.6/site-packages/pandas/io/html.py", line 743, in _parse 
    raise_with_traceback(retained) 
    File "/usr/local/lib/python3.6/site-packages/pandas/compat/__init__.py", line 344, in raise_with_traceback 
    raise exc.with_traceback(traceback) 
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)> 

這一直很直到現在,但我在這個特定的網站上有這個問題。另外,我是這方面的新手,對SSL證書不太瞭解,我在谷歌上搜索過它,但仍然沒有太多的知識。

回答

1

對於MAC
單擊Applications => Python,然後雙擊Install Certificates.command。

+2

但是,在應用程序中沒有Python ...你能告訴應用程序中的確切位置嗎?我假設Finder => Applications。 –

+0

請參閱https://stackoverflow.com/a/42098127/778533和https://stackoverflow.com/a/41692664/778533。 –

相關問題