Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

geopy.exc.GeocoderAuthenticationFailure: HTTP Error 401: Unauthorized

I'm trying to get the latitude and longitude of a location using GeoPy with Python. I tried implementing this question, as below:

from geopy.geocoders import GeoNames
gn = GeoNames(username='[my username]')
gn.geocode("Cleveland, OH 44106")

But I get this error:

geopy.exc.GeocoderAuthenticationFailure: HTTP Error 401: Unauthorized

I am registered on http://www.geonames.org, and I also tried looking at this question but I get the same error, unless the user_agent has to be specified somewhere with http://www.geonames.org?

What am I doing wrong?

like image 992
dd. Avatar asked Apr 12 '26 08:04

dd.


1 Answers

Turns out I had to enable Free Web Services at https://www.geonames.org/manageaccount when logged into my account, it works as expected now.

like image 180
dd. Avatar answered Apr 14 '26 22:04

dd.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!