ustroetz / python-osrm

A Python wrapper around the OSRM API
MIT License
129 stars 53 forks source link

ModuleNotFoundError: No module named 'polyline.codec' #59

Open RnoldR opened 11 months ago

RnoldR commented 11 months ago

I try to install osrm on Ubuntu 22.04. Installed the dependencies as listed in the README:

GDAL==3.4.3
geopandas==0.14.0
numpy==1.26.0
osrm==0.11.3
pandas==2.1.1
polyline==2.0.0

Apart from that I installed gdal-bin and libgdal-dev using apt install. When I import osrm I get:

$ python3
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import osrm
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/arnold/.local/lib/python3.10/site-packages/osrm/__init__.py", line 53, in <module>
    from .core import match, simple_route, nearest, table, trip, _chain
  File "/home/arnold/.local/lib/python3.10/site-packages/osrm/core.py", line 3, in <module>
    from polyline.codec import PolylineCodec
ModuleNotFoundError: No module named 'polyline.codec'

I could hardly find a suggestion on the net, except one remark that one should try to pip install polyline-decoder. That didn't help.

Does anyone have a suggestion? Thank you in advance.

francisvale commented 11 months ago

I believe this package is too old, most of the dependencies have changed. But to fix this issue go to the osrm folder package it should be something like this: C:\Users\admin\AppData\Local\Programs\Python\Python310\Lib\site-packages\osrm. Go to core.py > then delete the import of polyline.codec just a simple 'import polyline' will do, change the 'PolylineCodec().decode' with 'polyline.decode'.

you can see the that the decoding in polyline package here: https://github.com/frederickjansen/polyline

RnoldR commented 11 months ago

@francisvale Thanks! That worked but i now have the error: ImportError: cannot import name 'griddata' from 'matplotlib.mlab' (/usr/lib/python3/dist-packages/matplotlib/mlab.py). I followed the instructions I found in #33 but that did not help. Any suggestion on how to solve that.

As to the old version: I did the update as suggested in #33 and my current version is 0.11.3. Is this the latest version?

Shawn94 commented 9 months ago

@francisvale Thanks! That worked but i now have the error: ImportError: cannot import name 'griddata' from 'matplotlib.mlab' (/usr/lib/python3/dist-packages/matplotlib/mlab.py). I followed the instructions I found in #33 but that did not help. Any suggestion on how to solve that.

As to the old version: I did the update as suggested in #33 and my current version is 0.11.3. Is this the latest version?

Did you find solutions to this issue? I`m facing the same error...

jordanpaeth commented 8 months ago

for me the solution to the 'griddata' was same as

https://github.com/ustroetz/python-osrm/issues/36#issuecomment-1352622510