SSL: CERTIFICATE_VERIFY_FAILED with urllib

给你一囗甜甜゛ 提交于 2019-11-30 13:50:54
June

There is command line program that you can run on MacOsX that will install the certificates:

sudo /Applications/Python\ 3.6/Install\ Certificates.command

The sudo command will prompt for you password to elevate your privileges.

a dirty but fast hack like this do the job for me:

import ssl

ssl._create_default_https_context = ssl._create_unverified_context

I had the same issue. My python version is 3.6.5 and I'm on Mac OSX. When I tried to connect to the HTTPS sites I started getting the

<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)>

exception. So, it was so obvious to me that the python on my machine has no certificates. I just ran the file from the path /Applications/Python 3.6 with a file name Install Certificates.command. This solved my issue. I reffered to this post.

Xing Han

To fix the problem, open your bash and write:

cd /Applications/Python 3.6

then:

sudo Certificates.command
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!