Advertisement
olemis

GeocoderUnavailable HTTPSConnectionPool timeout error using geopandas

Apr 11th, 2023 (edited)
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.17 KB | None | 0 0
  1. ---------------------------------------------------------------------------
  2. TimeoutError Traceback (most recent call last)
  3. File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/urllib3/connectionpool.py:449, in HTTPConnectionPool._make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
  4. 445 except BaseException as e:
  5. 446 # Remove the TypeError from the exception chain in
  6. 447 # Python 3 (including for exceptions like SystemExit).
  7. 448 # Otherwise it looks like a bug in the code.
  8. --> 449 six.raise_from(e, None)
  9. 450 except (SocketTimeout, BaseSSLError, SocketError) as e:
  10.  
  11. File <string>:3, in raise_from(value, from_value)
  12.  
  13. File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/urllib3/connectionpool.py:444, in HTTPConnectionPool._make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
  14. 443 try:
  15. --> 444 httplib_response = conn.getresponse()
  16. 445 except BaseException as e:
  17. 446 # Remove the TypeError from the exception chain in
  18. 447 # Python 3 (including for exceptions like SystemExit).
  19. 448 # Otherwise it looks like a bug in the code.
  20.  
  21. File /usr/local/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py:1374, in HTTPConnection.getresponse(self)
  22. 1373 try:
  23. -> 1374 response.begin()
  24. 1375 except ConnectionError:
  25.  
  26. File /usr/local/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py:318, in HTTPResponse.begin(self)
  27. 317 while True:
  28. --> 318 version, status, reason = self._read_status()
  29. 319 if status != CONTINUE:
  30.  
  31. File /usr/local/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py:279, in HTTPResponse._read_status(self)
  32. 278 def _read_status(self):
  33. --> 279 line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  34. 280 if len(line) > _MAXLINE:
  35.  
  36. File /usr/local/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/socket.py:706, in SocketIO.readinto(self, b)
  37. 705 try:
  38. --> 706 return self._sock.recv_into(b)
  39. 707 except timeout:
  40.  
  41. File /usr/local/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ssl.py:1278, in SSLSocket.recv_into(self, buffer, nbytes, flags)
  42. 1275 raise ValueError(
  43. 1276 "non-zero flags not allowed in calls to recv_into() on %s" %
  44. 1277 self.__class__)
  45. -> 1278 return self.read(nbytes, buffer)
  46. 1279 else:
  47.  
  48. File /usr/local/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ssl.py:1134, in SSLSocket.read(self, len, buffer)
  49. 1133 if buffer is not None:
  50. -> 1134 return self._sslobj.read(len, buffer)
  51. 1135 else:
  52.  
  53. TimeoutError: The read operation timed out
  54.  
  55. During handling of the above exception, another exception occurred:
  56.  
  57. ReadTimeoutError Traceback (most recent call last)
  58. File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/urllib3/connectionpool.py:703, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
  59. 702 # Make the request on the httplib connection object.
  60. --> 703 httplib_response = self._make_request(
  61. 704 conn,
  62. 705 method,
  63. 706 url,
  64. 707 timeout=timeout_obj,
  65. 708 body=body,
  66. 709 headers=headers,
  67. 710 chunked=chunked,
  68. 711 )
  69. 713 # If we're going to release the connection in ``finally:``, then
  70. 714 # the response doesn't need to know about the connection. Otherwise
  71. 715 # it will also try to release it and we'll have a double-release
  72. 716 # mess.
  73.  
  74. File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/urllib3/connectionpool.py:451, in HTTPConnectionPool._make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
  75. 450 except (SocketTimeout, BaseSSLError, SocketError) as e:
  76. --> 451 self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  77. 452 raise
  78.  
  79. File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/urllib3/connectionpool.py:340, in HTTPConnectionPool._raise_timeout(self, err, url, timeout_value)
  80. 339 if isinstance(err, SocketTimeout):
  81. --> 340 raise ReadTimeoutError(
  82. 341 self, url, "Read timed out. (read timeout=%s)" % timeout_value
  83. 342 )
  84. 344 # See the above comment about EAGAIN in Python 3. In Python 2 we have
  85. 345 # to specifically catch it and throw the timeout error
  86.  
  87. ReadTimeoutError: HTTPSConnectionPool(host='photon.komoot.io', port=443): Read timed out. (read timeout=1)
  88.  
  89. During handling of the above exception, another exception occurred:
  90.  
  91. MaxRetryError Traceback (most recent call last)
  92. File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/requests/adapters.py:489, in HTTPAdapter.send(self, request, stream, timeout, verify, cert, proxies)
  93. 488 if not chunked:
  94. --> 489 resp = conn.urlopen(
  95. 490 method=request.method,
  96. 491 url=url,
  97. 492 body=request.body,
  98. 493 headers=request.headers,
  99. 494 redirect=False,
  100. 495 assert_same_host=False,
  101. 496 preload_content=False,
  102. 497 decode_content=False,
  103. 498 retries=self.max_retries,
  104. 499 timeout=timeout,
  105. 500 )
  106. 502 # Send the request.
  107. 503 else:
  108.  
  109. File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/urllib3/connectionpool.py:815, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
  110. 812 log.warning(
  111. 813 "Retrying (%r) after connection broken by '%r': %s", retries, err, url
  112. 814 )
  113. --> 815 return self.urlopen(
  114. 816 method,
  115. 817 url,
  116. 818 body,
  117. 819 headers,
  118. 820 retries,
  119. 821 redirect,
  120. 822 assert_same_host,
  121. 823 timeout=timeout,
  122. 824 pool_timeout=pool_timeout,
  123. 825 release_conn=release_conn,
  124. 826 chunked=chunked,
  125. 827 body_pos=body_pos,
  126. 828 **response_kw
  127. 829 )
  128. 831 # Handle redirect?
  129.  
  130. File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/urllib3/connectionpool.py:815, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
  131. 812 log.warning(
  132. 813 "Retrying (%r) after connection broken by '%r': %s", retries, err, url
  133. 814 )
  134. --> 815 return self.urlopen(
  135. 816 method,
  136. 817 url,
  137. 818 body,
  138. 819 headers,
  139. 820 retries,
  140. 821 redirect,
  141. 822 assert_same_host,
  142. 823 timeout=timeout,
  143. 824 pool_timeout=pool_timeout,
  144. 825 release_conn=release_conn,
  145. 826 chunked=chunked,
  146. 827 body_pos=body_pos,
  147. 828 **response_kw
  148. 829 )
  149. 831 # Handle redirect?
  150.  
  151. File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/urllib3/connectionpool.py:787, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
  152. 785 e = ProtocolError("Connection aborted.", e)
  153. --> 787 retries = retries.increment(
  154. 788 method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  155. 789 )
  156. 790 retries.sleep()
  157.  
  158. File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/urllib3/util/retry.py:592, in Retry.increment(self, method, url, response, error, _pool, _stacktrace)
  159. 591 if new_retry.is_exhausted():
  160. --> 592 raise MaxRetryError(_pool, url, error or ResponseError(cause))
  161. 594 log.debug("Incremented Retry for (url='%s'): %r", url, new_retry)
  162.  
  163. MaxRetryError: HTTPSConnectionPool(host='photon.komoot.io', port=443): Max retries exceeded with url: /api?q=SOME+ADRRESS%2C+Habana%2C+Cuba&limit=1 (Caused by ReadTimeoutError("HTTPSConnectionPool(host='photon.komoot.io', port=443): Read timed out. (read timeout=1)"))
  164.  
  165. During handling of the above exception, another exception occurred:
  166.  
  167. ConnectionError Traceback (most recent call last)
  168. File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/geopy/adapters.py:457, in RequestsAdapter._request(self, url, timeout, headers)
  169. 456 try:
  170. --> 457 resp = self.session.get(url, timeout=timeout, headers=headers)
  171. 458 except Exception as error:
  172.  
  173. File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/requests/sessions.py:600, in Session.get(self, url, **kwargs)
  174. 599 kwargs.setdefault("allow_redirects", True)
  175. --> 600 return self.request("GET", url, **kwargs)
  176.  
  177. File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/requests/sessions.py:587, in Session.request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
  178. 586 send_kwargs.update(settings)
  179. --> 587 resp = self.send(prep, **send_kwargs)
  180. 589 return resp
  181.  
  182. File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/requests/sessions.py:701, in Session.send(self, request, **kwargs)
  183. 700 # Send the request
  184. --> 701 r = adapter.send(request, **kwargs)
  185. 703 # Total elapsed time of the request (approximately)
  186.  
  187. File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/requests/adapters.py:565, in HTTPAdapter.send(self, request, stream, timeout, verify, cert, proxies)
  188. 563 raise SSLError(e, request=request)
  189. --> 565 raise ConnectionError(e, request=request)
  190. 567 except ClosedPoolError as e:
  191.  
  192. ConnectionError: HTTPSConnectionPool(host='photon.komoot.io', port=443): Max retries exceeded with url: /api?q=q=SOME+ADRRESS%2C+Habana%2C+Cuba&limit=1 (Caused by ReadTimeoutError("HTTPSConnectionPool(host='photon.komoot.io', port=443): Read timed out. (read timeout=1)"))
  193.  
  194. During handling of the above exception, another exception occurred:
  195.  
  196. GeocoderUnavailable Traceback (most recent call last)
  197. Cell In[63], line 1
  198. ----> 1 state_srl_locations = gpd.tools.geocode(df_state_srl['DIRECCION'],
  199. 2 provider=Photon)
  200. 3 state_srl_locations
  201.  
  202. File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/geopandas/tools/geocoding.py:67, in geocode(strings, provider, **kwargs)
  203. 64 provider = "photon"
  204. 65 throttle_time = _get_throttle_time(provider)
  205. ---> 67 return _query(strings, True, provider, throttle_time, **kwargs)
  206.  
  207. File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/geopandas/tools/geocoding.py:141, in _query(data, forward, provider, throttle_time, **kwargs)
  208. 139 try:
  209. 140 if forward:
  210. --> 141 results[i] = coder.geocode(s)
  211. 142 else:
  212. 143 results[i] = coder.reverse((s.y, s.x), exactly_one=True)
  213.  
  214. File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/geopy/geocoders/photon.py:166, in Photon.geocode(self, query, exactly_one, timeout, location_bias, language, limit, osm_tag, bbox)
  215. 164 logger.debug("%s.geocode: %s", self.__class__.__name__, url)
  216. 165 callback = partial(self._parse_json, exactly_one=exactly_one)
  217. --> 166 return self._call_geocoder(url, callback, timeout=timeout)
  218.  
  219. File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/geopy/geocoders/base.py:368, in Geocoder._call_geocoder(self, url, callback, timeout, is_json, headers)
  220. 366 try:
  221. 367 if is_json:
  222. --> 368 result = self.adapter.get_json(url, timeout=timeout, headers=req_headers)
  223. 369 else:
  224. 370 result = self.adapter.get_text(url, timeout=timeout, headers=req_headers)
  225.  
  226. File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/geopy/adapters.py:447, in RequestsAdapter.get_json(self, url, timeout, headers)
  227. 446 def get_json(self, url, *, timeout, headers):
  228. --> 447 resp = self._request(url, timeout=timeout, headers=headers)
  229. 448 try:
  230. 449 return resp.json()
  231.  
  232. File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/geopy/adapters.py:469, in RequestsAdapter._request(self, url, timeout, headers)
  233. 467 raise GeocoderServiceError(message)
  234. 468 else:
  235. --> 469 raise GeocoderUnavailable(message)
  236. 470 elif isinstance(error, requests.Timeout):
  237. 471 raise GeocoderTimedOut("Service timed out")
  238.  
  239. GeocoderUnavailable: HTTPSConnectionPool(host='photon.komoot.io', port=443): Max retries exceeded with url: /api?q=SOME+ADRRESS%2C+Habana%2C+Cuba&limit=1 (Caused by ReadTimeoutError("HTTPSConnectionPool(host='photon.komoot.io', port=443): Read timed out. (read timeout=1)"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement