Mac 下python3 [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed 解决方法

原文: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 进行安装,完毕后可以解决该问题。

python certificate verify failed

(或者在命令行中输入“/Applications/Python\ 3.6/Install\ Certificates.command”)

参考:
https://stackoverflow.com/questions/40684543/how-to-make-python-use-ca-certificates-from-mac-os-truststore

posted @ 2019-06-19 17:36  公众号python学习开发  阅读(3767)  评论(0编辑  收藏  举报