urllib3 warning ReadTimeoutError while connecting to Nominatim's geolocator

40 Views Asked by At

The code below code to extract pincodes, but raises the error below. How to work around this?

def get_zipcode(df, geolocator, lat_field, lon_field):
    location = geolocator.reverse(str(df[lat_field]) + "," + str(df[lon_field]))
    # print(location)    #-- uncomment this in case of checking the output
    #return location.raw['address']['postcode']
    
    if location == None:
        return "none"
    else:
        return location.raw['address'].get('postcode')

geolocator = geopy.Nominatim(user_agent="MyGeocodingScript")


zipcode = df.apply(get_zipcode, axis=1, geolocator=geolocator, lat_field='GPS_Lat', lon_field='GPS_Lon')

Error:

WARNING:urllib3.connectionpool:Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='nominatim.openstreetmap.org', port=443): Read timed out. (read timeout=1)")': /reverse?lat=11.2181948&lon=78.1811652&format=json&addressdetails=1
0

There are 0 best solutions below