我在使用 OSMNX 下载数据后尝试运行 dask;
Dask 抛出一个类型错误,如下所示;我尝试在运行 OSMNX 函数之前实现 Client(),它运行良好;在本地运行 Dask 之前下载文件会导致问题
我在 Ubuntu WSL 上运行 VSC;
study_area = study_area.geometry.unary_union
osm_graph= ox.graph.graph_from_polygon(study_area, network_type='drive')
osm_graph = ox.projection.project_graph(osm_graph, to_crs=local_crs)
streets = ox.consolidate_intersections(osm_graph, rebuild_graph=True, tolerance=15, dead_ends=False)
streets = ox.graph_to_gdfs(
osm_graph,
nodes=False,
edges=True,
node_geometry=False,
fill_edge_geometry=True
)
streets.head()
client = Client()
TypeError Traceback (most recent call last)
File ~/miniconda3/lib/python3.10/site-packages/tornado/tcpclient.py:265, in TCPClient.connect(self, host, port, af, ssl_options, max_buffer_size, source_ip, source_port, timeout)
261 addrinfo = await gen.with_timeout(
262 timeout, self.resolver.resolve(host, port, af)
263 )
264 else:
--> 265 addrinfo = await self.resolver.resolve(host, port, af)
266 connector = _Connector(
267 addrinfo,
268 functools.partial(
(...)
273 ),
274 )
275 af, addr, stream = await connector.start(connect_timeout=timeout)
File ~/miniconda3/lib/python3.10/site-packages/distributed/comm/tcp.py:476, in _DefaultLoopResolver.resolve(self, host, port, family)
466 async def resolve(
467 self, host: str, port: int, family: socket.AddressFamily = socket.AF_UNSPEC
468 ) -> list[tuple[int, Any]]:
(...)
472 # matter (we discard the one we get back in the results),
473 # so the addresses we return should still be usable with SOCK_DGRAM.
474 return [
475 (fam, address)
--> 476 for fam, _, _, _, address in await _getaddrinfo(
477 host, port, family=family, type=socket.SOCK_STREAM
478 )
479 ]
File ~/miniconda3/lib/python3.10/site-packages/distributed/comm/tcp.py:436, in _getaddrinfo(host, port, family, type)
429 if sys.version_info >= (3, 9):
430 # If host and port are numeric, then getaddrinfo doesn't block and we
431 # can skip get_running_loop().getaddrinfo which is implemented by
432 # running in a ThreadPoolExecutor. So we try first with the
433 # _NUMERIC_ONLY flags set, and then only use the threadpool if that
434 # fails with EAI_NONAME:
435 try:
--> 436 return socket.getaddrinfo(
437 host,
438 port,
439 family=family,
440 type=type,
441 flags=_NUMERIC_ONLY,
442 )
443 except socket.gaierror as e:
444 if e.errno != socket.EAI_NONAME:
TypeError: _config_dns.._getaddrinfo() got an unexpected keyword argument 'family'
这看起来像是 _getaddrinfo() 中 family 关键字参数的错误
你应该尝试更新 dask 和 tornado 到他们的最新版本
pip install --upgrade dask tornado
您也可以尝试通过替换 IP
来指定调度程序的 IP 地址
client = Client('tcp://<IP>:8786')