首页 > 解决方案 > SSL:在 Windows 上运行 python 程序时出现 CERTIFICATE_VERIFY_FAILED 错误

问题描述

我试图运行脚本并收到此错误(Python 3.6.5,Windows 10)。请注意,我已经尝试了几种解决方案,例如在 python 脚本中添加一些代码行。我也尝试从 Ubuntu 系统运行相同的脚本,但遇到了类似的错误。

导致此问题的代码行:

data = pd.read_csv(os.path.join(_fetch_file(
    'https://www.research.ibm.com/haifa/dept/vst/files/IBM_Debater_(R)_TR9856.v2.zip',
    'similarity', uncompress=True, verbose=0),
    'IBM_Debater_(R)_TR9856.v0.2', 'TermRelatednessResults.csv'), encoding="iso-8859-1")

完整日志:

Traceback (most recent call last):
  File "C:\Users\oleg\AppData\Local\Continuum\anaconda3\lib\urllib\request.py", line 1318, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "C:\Users\oleg\AppData\Local\Continuum\anaconda3\lib\http\client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "C:\Users\oleg\AppData\Local\Continuum\anaconda3\lib\http\client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "C:\Users\oleg\AppData\Local\Continuum\anaconda3\lib\http\client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "C:\Users\oleg\AppData\Local\Continuum\anaconda3\lib\http\client.py", line 1026, in _send_output
    self.send(msg)
  File "C:\Users\oleg\AppData\Local\Continuum\anaconda3\lib\http\client.py", line 964, in send
    self.connect()
  File "C:\Users\oleg\AppData\Local\Continuum\anaconda3\lib\http\client.py", line 1400, in connect
    server_hostname=server_hostname)
  File "C:\Users\oleg\AppData\Local\Continuum\anaconda3\lib\ssl.py", line 407, in wrap_socket
    _context=self, _session=session)
  File "C:\Users\oleg\AppData\Local\Continuum\anaconda3\lib\ssl.py", line 814, in __init__
    self.do_handshake()
  File "C:\Users\oleg\AppData\Local\Continuum\anaconda3\lib\ssl.py", line 1068, in do_handshake
    self._sslobj.do_handshake()
  File "C:\Users\oleg\AppData\Local\Continuum\anaconda3\lib\ssl.py", line 689, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./scripts/evaluate_on_all.py", line 85, in <module>
    results = evaluate_on_all(w)
  File "C:\Users\oleg\AppData\Local\Continuum\anaconda3\lib\site-packages\web-0.0.1-py3.6.egg\web\evaluate.py", line 370, in evaluate_on_all
    "TR9856": fetch_TR9856(),
  File "C:\Users\oleg\AppData\Local\Continuum\anaconda3\lib\site-packages\web-0.0.1-py3.6.egg\web\datasets\similarity.py", line 335, in fetch_TR9856
    'similarity', uncompress=True, verbose=0),
  File "C:\Users\oleg\AppData\Local\Continuum\anaconda3\lib\site-packages\web-0.0.1-py3.6.egg\web\datasets\utils.py", line 741, in _fetch_file
    handlers=handlers)
  File "C:\Users\oleg\AppData\Local\Continuum\anaconda3\lib\site-packages\web-0.0.1-py3.6.egg\web\datasets\utils.py", line 648, in _fetch_helper
    data = url_opener.open(request)
  File "C:\Users\oleg\AppData\Local\Continuum\anaconda3\lib\urllib\request.py", line 526, in open
    response = self._open(req, data)
  File "C:\Users\oleg\AppData\Local\Continuum\anaconda3\lib\urllib\request.py", line 544, in _open
    '_open', req)
  File "C:\Users\oleg\AppData\Local\Continuum\anaconda3\lib\urllib\request.py", line 504, in _call_chain
    result = func(*args)
  File "C:\Users\oleg\AppData\Local\Continuum\anaconda3\lib\urllib\request.py", line 1361, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "C:\Users\oleg\AppData\Local\Continuum\anaconda3\lib\urllib\request.py", line 1320, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)>

标签: pythonpython-3.xsslssl-certificate

解决方案


推荐阅读