Hi guys,
I am trying to geocode an address into latitude and longitude. For that, I used
https://geopy.readthedocs.io/en/stable/
However, I got the error below. When I looked through the forums, it seems that pythonanywhere needs to whitelist that connection first. Can you confirm and indicate whether you can whitelist that functionality?
Thank you
M
Error:
2018-11-21 07:44:19,690: Exception on /demo/api/v2.0/predictbuy [GET]
Traceback (most recent call last):
File "/usr/lib/python3.6/urllib/request.py", line 1318, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "/usr/lib/python3.6/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1026, in _send_output
self.send(msg)
File "/usr/lib/python3.6/http/client.py", line 964, in send
self.connect()
File "/usr/lib/python3.6/http/client.py", line 1392, in connect
super().connect()
File "/usr/lib/python3.6/http/client.py", line 940, in connect
self._tunnel()
File "/usr/lib/python3.6/http/client.py", line 919, in _tunnel
message.strip()))
OSError: Tunnel connection failed: 403 Forbidden
**NO MATCH**
During handling of the above exception, another exception occurred:
**NO MATCH**
Traceback (most recent call last):
File "/home/ehlersanalytics/.virtualenvs/my-virtualenv/lib/python3.6/site-packages/geopy/geocoders/base.py", line 344, in _call_geocoder
page = requester(req, timeout=timeout, **kwargs)
File "/usr/lib/python3.6/urllib/request.py", line 526, in open
response = self._open(req, data)
File "/usr/lib/python3.6/urllib/request.py", line 544, in _open
'_open', req)
File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/usr/lib/python3.6/urllib/request.py", line 1361, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/usr/lib/python3.6/urllib/request.py", line 1320, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error Tunnel connection failed: 403 Forbidden>
**NO MATCH**
During handling of the above exception, another exception occurred:
**NO MATCH**
Traceback (most recent call last):
File "/home/ehlersanalytics/.virtualenvs/my-virtualenv/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/home/ehlersanalytics/.virtualenvs/my-virtualenv/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/ehlersanalytics/.virtualenvs/my-virtualenv/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/ehlersanalytics/.virtualenvs/my-virtualenv/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/home/ehlersanalytics/.virtualenvs/my-virtualenv/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/home/ehlersanalytics/.virtualenvs/my-virtualenv/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/ehlersanalytics/mysite/flask_app.py", line 486, in get_prediction_buy_v2
location = photon.geocode(address)
File "/home/ehlersanalytics/.virtualenvs/my-virtualenv/lib/python3.6/site-packages/geopy/geocoders/photon.py", line 145, in geocode
self._call_geocoder(url, timeout=timeout),
File "/home/ehlersanalytics/.virtualenvs/my-virtualenv/lib/python3.6/site-packages/geopy/geocoders/base.py", line 375, in _call_geocoder
raise GeocoderServiceError(message)
geopy.exc.GeocoderServiceError: Tunnel connection failed: 403 Forbidden
[edit by admin: formatting]