原文:http://blog.yuccn.net/archives/625.html
python3.6下使用urllib 的request進行url 請求時候,如果請求的是https,請求可以會出現
“urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)>”
錯誤棧(部分):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 544, in _open '_open', req) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 504, in _call_chain result = func(*args) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1361, in https_open context=self._context, check_hostname=self._check_hostname) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/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:749)>
解決方案
進入應用程序的Python 3.6目錄,雙擊Install Certificates.command 進行安裝,完畢后可以解決該問題。
(或者在命令行中輸入“/Applications/Python\ 3.6/Install\ Certificates.command”)