title: Python urllib.urlopen gives [SSL: CERTIFICATE_VERIFY_FAILED] error
body: <p>I'm relatively new to Python. Trying to write a function in Python that will calculate the distance between locations using the Google Distance Matrix API. I actually have used this code successfully in the past, but now I am getting the following error and can't figure out what is going on.</p>
  
  <p>IOError: [Errno socket error] [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)</p>
  
  <p>I know the issue isn't with the URL because I can type it in a browser, using my API key, and it gives me the result I'm looking for (i.e., distance info from Google Maps Distance Matrix API). It seems to be an issue with the urllib.urlopen function call. I assume I'm calling it incorrectly somehow, but I can't figure out how. Any ideas?</p>
  
  <p>I'm using Python version 2.7.10.</p>
  
  <pre><code>import urllib
  import re
  
  def getMiles(origin,destination):
      #APIkey = "someAPIkey"  #Update to prompt user for API key
      query = "https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&amp;origins=" + origin + "&amp;destinations=" + destination + "&amp;key=" + APIkey
      test = 0
  
  fhand = urllib.urlopen(query)  #CODE ERRORS OUT HERE
  #Error handling to ensure query works
  try:
      for line in fhand:
          line = str(line.strip())
          #print line
          if test == 1:
              line = line.replace('"text" : "',"")
              line = line.replace('",',"")
              result = [origin,'"'+destination+'"'] + line.split()
              break
          if line.startswith('"distance"'):
              test = 1
      return result
  except:
      result = [origin,'"'+destination+'"',"ERROR","Query could not be opened"]
      return result
  </code></pre>