NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

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!

asked 28 Jul '17, 19:22

Jimmy_Jin's gravatar image

Jimmy_Jin
31223
accept rate: 0%


I'm pretty sure your local Nominatim installation runs on http://localhost:8080/nominatim/search?format=jsonv2&q=Berlin&limit=1 Note the /nominatim part of the path that the server nominatim.openstreetmap.org is missing.

Try

nom = Nominatim(domain='localhost:8080/nominatim', scheme='http')

permanent link

answered 28 Jul '17, 23:17

mtmail's gravatar image

mtmail
4.8k1574
accept rate: 27%

edited 28 Jul '17, 23:22

by try I mean that worked when I ran it against my local Nominatim

(28 Jul '17, 23:27) mtmail
1

My link does not actually contain nomination : 'http://127.0.0.1:8080/search.php?q=Berlin&polygon=1&viewbox=' I find the wrong part is: nom=Nominatim(domain='http://localhost:8080')

the correct form is

nom=Nominatim(domain='localhost:8080', scheme='http')

I got hint from your answer, thanks.

(28 Jul '17, 23:39) Jimmy_Jin
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×689

question asked: 28 Jul '17, 19:22

question was seen: 5,278 times

last updated: 28 Jul '17, 23:39

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum