Python 自己的命名服务器不与geopy一起工作

Python 自己的命名服务器不与geopy一起工作,python,geocoding,geopy,nominatim,Python,Geocoding,Geopy,Nominatim,我有一个超过6k个地址条目的数据库,需要进行地理编码,因此我安装了带有docker的Namingm服务器进行地理编码工作。它在“localhost:8080”上的web表单中正常工作 然而,当我尝试在jupyter中使用geopy进行查询时。它总是抛出错误 我的Jupyter代码: from geopy.geocoder import Nominatim nom=Nominatim(domain='http://localhost:8080') nom.geocode('some address

我有一个超过6k个地址条目的数据库,需要进行地理编码,因此我安装了带有docker的Namingm服务器进行地理编码工作。它在“localhost:8080”上的web表单中正常工作

然而,当我尝试在jupyter中使用geopy进行查询时。它总是抛出错误

我的Jupyter代码:

from geopy.geocoder import Nominatim
nom=Nominatim(domain='http://localhost:8080')
nom.geocode('some address') #the address works on the public server
错误堆栈:

---------------------------------------------------------------------------
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
---------------------------------------------------------------------------
GAIRROR回溯(最近一次呼叫最后一次)
/do_open中的usr/local/ceral/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py(self,http_类,req,**http_conn_参数)
1253尝试:
->1254 h.request(请求获取方法(),请求选择器,请求数据,标题)
1255除OSError as err外:#超时错误
/请求中的usr/local/ceral/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py(self、方法、url、正文、标题)
1105“向服务器发送完整的请求。”“”
->1106自发送请求(方法、url、正文、标题)
1107
/usr/local/ceral/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py in_send_请求(self、方法、url、正文、标题)
1150 body=_编码(body,'body')
->1151自结束标题(正文)
1152
/endheaders中的usr/local/ceral/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py(self,message_body)
1101升起CannotSendHeader()
->1102自发送输出(消息体)
1103
/usr/local/ceral/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py in_发送_输出(self,message_body)
933
-->934自动发送(msg)
935如果消息体不是无:
/发送中的usr/local/ceral/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py(self,data)
876如果self.auto_打开:
-->877 self.connect()
878其他:
/connect(self)中的usr/local/ceral/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py
1251
->1252 super().connect()
1253
/connect(self)中的usr/local/ceral/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py
848 self.sock=self.\u创建\u连接(
-->849(self.host、self.port)、self.timeout、self.source\u地址)
850 self.sock.setsockopt(socket.IPPROTO_TCP,socket.TCP_NODELAY,1)
/创建连接(地址、超时、源地址)中的usr/local/ceral/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/socket.py
692错误=无
-->693对于getaddrinfo中的res(主机、端口、0、SOCK_流):
694 af,socktype,proto,canonname,sa=res
/getaddrinfo中的usr/local/ceral/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/socket.py(主机、端口、系列、类型、原型、标志)
731地址列表=[]
-->732对于_socket.getaddrinfo(主机、端口、系列、类型、协议、标志)中的res:
733 af,socktype,原型,canonname,sa=res
gaierror:[Errno 8]提供了节点名或服务名,或者未知
在处理上述异常期间,发生了另一个异常:
URLError回溯(最近一次调用上次)
/Users/nmbqz/.virtualenvs/scrapy/lib/python3.5/site-packages/geopy/geocoders/base.py in\u call\u geocoder(self、url、超时、raw、请求者、反序列化者、**kwargs)
142尝试:
-->143页=请求者(请求,超时=(超时或自超时),**kwargs)
144例外情况除外,因为错误:#pylint:disable=W0703
/urlopen中的usr/local/ceral/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py(url、数据、超时、cafile、capath、cadefault、上下文)
162开瓶器=_开瓶器
-->163返回opener.open(url、数据、超时)
164
/usr/local/ceral/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py处于打开状态(self、fullurl、数据、超时)
465
-->466响应=自身打开(请求,数据)
467
/usr/local/ceral/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py in_open(self、req、data)
483结果=self.\u调用\u链(self.handle\u打开,协议,协议+
-->484'_open',请求)
485如果结果:
/usr/local/ceral/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(处理程序,方法名称)
-->444结果=函数(*args)
445如果结果不是无:
/https_open(self,req)中的usr/local/ceral/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py
1296返回self.do_open(http.client.HTTPSConnection,req,
->1297 context=self.\u context,check\u hostname=self.\u check\u hostname)
1298
/do_open中的usr/local/ceral/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py(self,http_类,req,**http_conn_参数)
1255除OSError as err外:#超时错误
->1256 raise URLRERROR(错误)
1257 r=h.getresponse()
URL错误:
在处理上述异常期间,发生了另一个异常:
GeocoderServiceError回溯(最近一次调用)
在()
---->1名称地理代码(“Revontulentie 11”)
/地理编码中的Users/nmbqz/.virtualenvs/scrapy/lib/python3.5/site-packages/geopy/geocoders/osm.py(self、query、executes、timeout、addressdetails、language、geometry)
191 logger.debug(“%s.geocode:%s”,self.\uuuuuuuu class.\uuuuuuuuu name\uuuuuu,url)
192返回self.\u解析\u json(
-->193 self.\u call\u地理编码器(url,timeout=timeou
nom=Nominatim(domain='localhost:8080', scheme='http')
self.domain = domain.strip('/')
self.api = "%s://%s/search" % (self.scheme, self.domain)