pythongeopygeonames

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?


Solution

  • 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.