Forums

Is geopy,haversine package available to use with pythonanywhere

I am running my startup website which takes location and I need the address from those location coordinates.Are they available for use in my code? EDIT: SO i used geopy in my code but i get the following error:

<urlopen error Tunnel connection failed: 403 Forbidden>

What is the solution for this problem reply asap!Please<br>Thanks in advance

What site are you trying to access? Free accounts have restricted Internet access, to whitelisted sites only: https://www.pythonanywhere.com/whitelist/

For anyone interested, it looks like the 403 was coming from a geopy geocoder called Nominatim:

That's a service provided by openstreetmap: https://wiki.openstreetmap.org/wiki/Nominatim, and so geopy needs to call out to the openstreetmap site, and that's not on our whitelist, so the proxy blocks it with a 403.

The OpenStreetMap API limits people to a maximum of 1 request per second, and I don't think they'd be able to tell the difference between different PythonAnywhere users on the same server, so I don't think we're going to be able to whitelist this one.

But you can probably use one of the alternative geopy geolocators: there's several listed here:

https://geopy.readthedocs.org/en/1.10.0/#module-geopy.geocoders

so, eg, use

from geopy import geocoders
geocoder = geocoders.GoogleV3()    # instead of geocoders.Nominatim()