python - 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)>
解决方案
推荐阅读
- javascript - NodeJS:如何断言是否使用 sinon 调用了事件回调函数
- protractor - 如何在量角器中选择日期选择器的日期
- javascript - 有没有办法将父 css 泄漏到 Vue 中的子组件?
- asp.net-core - TestHost 生成无效的 URI:无法确定 URI 的格式
- elasticsearch - 为什么文件没有被删除?deleteByQuery 成功但不删除任何内容
- gradle - java.lang.NoSuchFieldError: gradle artifactoryPublish 任务期间的 INSTANCE 错误
- javascript - “addEventListener”在幕后是如何工作的?
- drupal - Drupal 7:如何发送 HTML 电子邮件
- android-studio - 为什么我的 Android Layout Design 在我的智能手机上无法正常工作
- video-intelligence-api - Google Cloud Video Intelligence API 中的本地文件是否有视频大小限制?