google-api-python-client: urllib2.URLError:

Heads up!

We appreciate any bug reports or other contributions, but please note that this issue tracker is only for this client library. We do not maintain the APIs that this client library talks to. If you have an issue or questions with how to use a particular API, you may be better off posting on Stackoverflow under the google-api tag. If you are reporting an issue or requesting a feature for a G Suite API, please use their public issue tracker

Thank you!

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (5 by maintainers)

Most upvoted comments

This helped resolve my issue: Thanks to the blog by Yifan Peng : http://blog.pengyifan.com/how-to-fix-python-ssl-certificate_verify_failed/

I added the below code:

import os, ssl
if (not os.environ.get('PYTHONHTTPSVERIFY', '') and
    getattr(ssl, '_create_unverified_context', None)): 
    ssl._create_default_https_context = ssl._create_unverified_context

For the record, this error is almost certainly due to the following combination of events:

  • The certificate database of the operating system on which the script is run is outdated.

  • You are running Python 2 >= 2.7.9 or Python 3 >= 3.4

In these versions of Python, SSL certificate verification is turned on by default (in previous versions, it was turned off by default). The solution is to update your OS’ certificate database, which differs greatly per OS.

For more information:

https://www.python.org/dev/peps/pep-0476/