Calling `from_geocode` occasionally produces "list index out of range" error
See original GitHub issueI’ve been using gmplot to draw running routes (via tcx files). Until recently I could loop through a file list and generate the new html plots.
But now the loop will seemingly-spontaneously fail and generate the following error:
40 'http://maps.googleapis.com/maps/api/geocode/json?address="%s"' % location_string) 41 geocode = json.loads(geocode.text)—> 42 latlng_dict = geocode[‘results’][0][‘geometry’][‘location’] 43 return latlng_dict[‘lat’], latlng_dict[‘lng’] 44
IndexError: list index out of range
I was able to isolate it to the call for
gmap = gmplot.GoogleMapPlotter.from_geocode("San Francisco")
For example, running the following code will result in throwing an error at some point (usually in the 8-14 range):
for i in range(25):
print(i)
gmap = gmplot.GoogleMapPlotter.from_geocode("San Francisco")
I can wrap it in a try/except but that merely delays the break.
My naive guess is that I’m breaking some API limit.
Issue Analytics
- State:
- Created 6 years ago
- Comments:16 (3 by maintainers)
Top Results From Across the Web
Python Google Geocoding API - IndexError: list index out of ...
I'm having a problem with the API where I keep getting an error. Let me show the code, first. # import necessary modules...
Read more >What Does the Python "List index out of range" Error Mean?
When Python throws a "list index out of range" error, it means you tried to slice the list beyond its last index. Python...
Read more >How to fix 'Sys.argv [1], indexerror: list index out of range ...
It means you are calling for the position of an element of the list higher than the amount of elements. If you have...
Read more >Geocoding Service | Maps JavaScript API - Google Developers
"ERROR" indicates that the request timed out or there was a problem contacting the Google servers. The request may succeed if you try...
Read more >Welcome to GeoPy's documentation! — GeoPy 2.3.0 ...
Refer to the specific geocoder's initializer doc for a list of parameters which that ... (e.g. by returning Too Many Requests 429 HTTP...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

fixed with:
ie you’re forced to pass and API key (as gmaps forces you to)
Any chance this can get merged into the official release? Or do I need to fork yet another project to fix bugs that have had a solution sitting around in some other fork for a while?