ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c: 748)

2

I'm using geopy in an application Python 3.6 and I have to run it on an outdated machine that uses Windows 2012 Server . The problem arises when the application calls this library ( geopy ) on this server, since it returns the following error:

File "C:\ServAPI\Util.py", line 12, in getLocation
location = geolocator.geocode(name)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\geopy\geocoders\osm.py", line 193, in geocode
self._call_geocoder(url, timeout=timeout), exactly_one
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\geopy\geocoders\base.py", line 171, in _call_geocoder
raise GeocoderServiceError(message)
geopy.exc.GeocoderServiceError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)

Does anyone know how to solve this error? Thanks

UPDATE

The code that gives the error is the following:

from geopy.geocoders import Nominatim
from geopy.exc import GeocoderTimedOut
# Dado el nombre de una ciudad, devuelve sus coordenadas
def getLocation(name):
    geolocator = Nominatim()
    try:
        location = geolocator.geocode(name, timeout=5)
        return location
    except GeocoderTimedOut as e:
        print("Error: geocode failed on input %s with message %s" % (e.msg))

Also, when I run it on my local machine ( Windows 10 ), it works without problems (already, I know, it sounds like "it works for me locally", but it's the truth)

    
asked by jjmartinez 04.10.2017 в 10:14
source

1 answer

2

Possibly, in win2012 the SSL library is outdated. Try explicitly stating that the scheme is http :

from geopy.geocoders import Nominatim
from geopy.exc import GeocoderTimedOut

# Dado el nombre de una ciudad, devuelve sus coordenadas
def getLocation(name):
    geolocator = Nominatim(scheme='http')
    try:
        location = geolocator.geocode(name, timeout=5)
        return location
    except GeocoderTimedOut as e:
        print("Error: geocode failed on input %s with message %s" % (e.msg))
    
answered by 04.10.2017 / 15:16
source