genthalili / searoute-py

A python package to calculate the shortest sea route between two points on Earth.
Apache License 2.0
63 stars 14 forks source link

Error running sr.searoute(origin, destination); ImportError: scikit-learn must be installed to search an unprojected graph #17

Closed bmm23 closed 1 year ago

bmm23 commented 1 year ago

ImportError Traceback (most recent call last) Cell In[27], line 3 1 origin = [0.3515625, 50.064191736659104] 2 destination = [117.42187500000001, 39.36827914916014] ----> 3 route = sr.searoute(origin, destination)

File c:\Users\389023\AppData\Local\Programs\Python\Python310\lib\site-packages\searoute\searoute.py:223, in searoute(origin, destination, units, speed_knot, append_orig_dest, restrictions, include_ports, port_params) 220 port_dest = closestPortDest[1] 222 # In the graph, get the nodes closest to the points --> 223 origin_node = ox.distance.nearest_nodes(H, origin[0], origin[1]) 224 destination_node = ox.distance.nearest_nodes(H, destination[0], destination[1]) 226 # Get the shortest route by distance

File c:\Users\389023\AppData\Local\Programs\Python\Python310\lib\site-packages\osmnx\distance.py:227, in nearest_nodes(G, X, Y, return_dist) 224 else: 225 # if unprojected, use ball tree for haversine nearest-neighbor search 226 if BallTree is None: # pragma: no cover --> 227 raise ImportError("scikit-learn must be installed to search an unprojected graph") 228 # haversine requires lat, lng coords in radians 229 nodes_rad = np.deg2rad(nodes[["y", "x"]])

ImportError: scikit-learn must be installed to search an unprojected graph

Code being run: origin = [0.3515625, 50.064191736659104] destination = [117.42187500000001, 39.36827914916014] route = sr.searoute(origin, destination)

Edit: Solved by restarting VSCode