I have a database of over 6k entries of addresses need for geocoding, thus I have installed nominatim server with docker for geocoding work. It works as it should in the web form on the 'localhost:8080'.
However, when I try to query with geopy in jupyter. It throws error all the time.
My Jupyter code:
from geopy.geocoder import Nominatim
nom=Nominatim(domain='http://localhost:8080')
nom.geocode('some address') #the address works on the public server
The error stack:
gaierror Traceback (most recent call last)
/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py in do_open(self, http_class, req, **http_conn_args)
1253 try:
-> 1254 h.request(req.get_method(), req.selector, req.data, headers)
1255 except OSError as err: # timeout error
/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py in request(self, method, url, body, headers)
1105 """Send a complete request to the server."""
-> 1106 self._send_request(method, url, body, headers)
1107
/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py in _send_request(self, method, url, body, headers)
1150 body = _encode(body, 'body')
-> 1151 self.endheaders(body)
1152
/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py in endheaders(self, message_body)
1101 raise CannotSendHeader()
-> 1102 self._send_output(message_body)
1103
/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py in _send_output(self, message_body)
933
--> 934 self.send(msg)
935 if message_body is not None:
/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py in send(self, data)
876 if self.auto_open:
--> 877 self.connect()
878 else:
/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py in connect(self)
1251
-> 1252 super().connect()
1253
/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py in connect(self)
848 self.sock = self._create_connection(
--> 849 (self.host,self.port), self.timeout, self.source_address)
850 self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/socket.py in create_connection(address, timeout, source_address)
692 err = None
--> 693 for res in getaddrinfo(host, port, 0, SOCK_STREAM):
694 af, socktype, proto, canonname, sa = res
/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/socket.py in getaddrinfo(host, port, family, type, proto, flags)
731 addrlist = []
--> 732 for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
733 af, socktype, proto, canonname, sa = res
gaierror: [Errno 8] nodename nor servname provided, or not known
During handling of the above exception, another exception occurred:
URLError Traceback (most recent call last)
/Users/nmbqz/.virtualenvs/scrapy/lib/python3.5/site-packages/geopy/geocoders/base.py in _call_geocoder(self, url, timeout, raw, requester, deserializer, **kwargs)
142 try:
--> 143 page = requester(req, timeout=(timeout or self.timeout), **kwargs)
144 except Exception as error: # pylint: disable=W0703
/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
162 opener = _opener
--> 163 return opener.open(url, data, timeout)
164
/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py in open(self, fullurl, data, timeout)
465
--> 466 response = self._open(req, data)
467
/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py in _open(self, req, data)
483 result = self._call_chain(self.handle_open, protocol, protocol +
--> 484 '_open', req)
485 if result:
/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args)
443 func = getattr(handler, meth_name)
--> 444 result = func(*args)
445 if result is not None:
/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py in https_open(self, req)
1296 return self.do_open(http.client.HTTPSConnection, req,
-> 1297 context=self._context, check_hostname=self._check_hostname)
1298
/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py in do_open(self, http_class, req, **http_conn_args)
1255 except OSError as err: # timeout error
-> 1256 raise URLError(err)
1257 r = h.getresponse()
URLError: <urlopen error [Errno 8] nodename nor servname provided, or not known>
During handling of the above exception, another exception occurred:
GeocoderServiceError Traceback (most recent call last)
<ipython-input-141-ad9610064de4> in <module>()
----> 1 nom.geocode('Revontulentie 11')
/Users/nmbqz/.virtualenvs/scrapy/lib/python3.5/site-packages/geopy/geocoders/osm.py in geocode(self, query, exactly_one, timeout, addressdetails, language, geometry)
191 logger.debug("%s.geocode: %s", self.__class__.__name__, url)
192 return self._parse_json(
--> 193 self._call_geocoder(url, timeout=timeout), exactly_one
194 )
195
/Users/nmbqz/.virtualenvs/scrapy/lib/python3.5/site-packages/geopy/geocoders/base.py in _call_geocoder(self, url, timeout, raw, requester, deserializer, **kwargs)
169 if "timed out" in message:
170 raise GeocoderTimedOut('Service timed out')
--> 171 raise GeocoderServiceError(message)
172
173 if hasattr(page, 'getcode'):
GeocoderServiceError: [Errno 8] nodename nor servname provided, or not known
Appreciate some clues!