我试图将Python作为一种业余爱好,但遇到了一些错误。我认为这个错误与在某个地方没有()有关,但我不确定我可能在哪里错过了这个。我已经上传了到目前为止的内容。我还将上传我收到的错误消息的截图。提前感谢您的帮助或建议。我会继续搜索/尝试解决这个问题
import osmnx
import osmnx as ox
import networkx as nx
ox.config(log_console=True, use_cache=True)
#define start and ending of latitude and longitude
start_latlng = (41.643080, -86.767860)
end_latlng = (41.641450, -86.764640)
# Location where you want to find the route
place = 'La Porte, Indiana, United States'
# Find the shortest route based on mode of travel
mode = 'drive'
# Find shortest path based on distance
optimizer = 'time'
#create a graph from OSM within the boundaries of some geocodeable place
graph = ox.graph_from_place(place, network_type=mode)
# Find the nearest node to the start location
orig_node = osmnx.nearest_nodes(graph, start_latlng)
# Find nearest node to end location
dest_node = osmnx.nearest_nodes(graph, end_latlng)
# Find shortest path
shortest_route = nx.shortest_paths(graph,
orig_node,
dest_node,
weight=optimizer)