Geopy: catch timeout error

前端 未结 3 1535
难免孤独
难免孤独 2020-12-09 03:22

I am using geopy to geocode some addresses and I want to catch the timeout errors and print them out so I can do some quality control on the input. I am putting the geocode

3条回答
  •  天命终不由人
    2020-12-09 04:11

    I dealt with the Same Problem for so many days this is my code:

    geolocator = Nominatim(user_agent="ny_explorer")
    location = geolocator.geocode(address_venue)
    

    ERROR Service timed out

    solution: Add a new attribute that declares the timeout:

    location = geolocator.geocode(address_venue,timeout=10000)
    

提交回复
热议问题