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 searoute #16

Closed damilare-osunleke closed 10 months ago

damilare-osunleke commented 1 year ago

Running the sample code (shown below) in the readme returns an error: "ImportError: scikit-learn must be installed to search an unprojected graph"

import searoute as sr origin = [0.3515625, 50.064191736659104] destination = [117.42187500000001, 39.36827914916014] route = sr.searoute(origin, destination)

Note:I have scikit-learn installed

damilare-osunleke commented 1 year ago

issue resolved

bmm23 commented 1 year ago

I'm having the same issue right now as well.

Full error:

ImportError Traceback (most recent call last) Cell In[10], 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

damilare-osunleke commented 1 year ago

In my case, I closed and reopened my code editor (VScode) and restarted the session and it was fine.

Maybe you could try the same thing.

bmm23 commented 1 year ago

@damilare-osunleke That fixed it, thanks

genthalili commented 10 months ago

Closing, feel free to open a new issues if this occurs