ustroetz / python-osrm

A Python wrapper around the OSRM API
MIT License
133 stars 55 forks source link

No module named 'polyline.codec' #56

Closed RnoldR closed 1 year ago

RnoldR commented 1 year ago

I installed osrm with "pip install osrm". When I import osrm in python I get the message:

 >>> import osrm

Traceback (most recent call last): File "", line 1, in File "/home/arnold/bin/anaconda/envs/ot/lib/python3.9/site-packages/osrm/init.py", line 53, in from .core import match, simple_route, nearest, table, trip, _chain File "/home/arnold/bin/anaconda/envs/ot/lib/python3.9/site-packages/osrm/core.py", line 3, in from polyline.codec import PolylineCodec ModuleNotFoundError: No module named 'polyline.codec'

When I look into the polyline code there is no such thing as codec or PolyLineCodec. Any idea what causes this error?

osrm version 0.11.3, polyline 2.0.0 ubuntu 22.04

$ pip freeze action-msgs==1.2.1 actionlib-msgs==4.2.3 ament-cmake-test==1.3.3 ament-copyright==0.12.5 ament-cppcheck==0.12.5 ament-cpplint==0.12.5 ament-flake8==0.12.5 ament-index-python==1.4.0 ament-lint==0.12.5 ament-lint-cmake==0.12.5 ament-package==0.14.0 ament-pep257==0.12.5 ament-uncrustify==0.12.5 ament-xmllint==0.12.5 appdirs==1.4.4 asttokens @ file:///opt/conda/conda-bld/asttokens_1646925590279/work attrs @ file:///croot/attrs_1668696182826/work backcall @ file:///home/ktietz/src/ci/backcall_1611930011877/work Bottleneck @ file:///opt/conda/conda-bld/bottleneck_1657175564434/work branca @ file:///croot/branca_1675157607453/work brotlipy==0.7.0 builtin-interfaces==1.2.1 certifi @ file:///croot/certifi_1671487769961/work/certifi cffi @ file:///croot/cffi_1670423208954/work charset-normalizer @ file:///tmp/build/80754af9/charset-normalizer_1630003229654/work click @ file:///tmp/build/80754af9/click_1646056590078/work click-plugins @ file:///Users/ktietz/demo/mc3/conda-bld/click-plugins_1630665883852/work cligj==0.7.2 composition-interfaces==1.2.1 contourpy @ file:///opt/conda/conda-bld/contourpy_1663827406301/work cryptography @ file:///croot/cryptography_1677533068310/work cycler @ file:///tmp/build/80754af9/cycler_1637851556182/work decorator @ file:///opt/conda/conda-bld/decorator_1643638310831/work diagnostic-msgs==4.2.3 domain-coordinator==0.10.0 executing @ file:///opt/conda/conda-bld/executing_1646925071911/work Fiona @ file:///croot/fiona_1678226032672/work folium @ file:///croot/folium_1675353398721/work fonttools==4.25.0 GDAL==3.6.2 geometry-msgs==4.2.3 geopandas @ file:///croot/geopandas_1675672011738/work idna @ file:///croot/idna_1666125576474/work importlib-resources @ file:///tmp/build/80754af9/importlib_resources_1625135880749/work ipython @ file:///croot/ipython_1676582224036/work jedi @ file:///tmp/build/80754af9/jedi_1644297102865/work Jinja2 @ file:///croot/jinja2_1666908132255/work joblib @ file:///croot/joblib_1666298844297/work kiwisolver @ file:///croot/kiwisolver_1672387140495/work launch==1.0.4 launch-ros==0.19.4 launch-testing==1.0.4 launch-testing-ros==0.19.4 launch-xml==1.0.4 launch-yaml==1.0.4 lifecycle-msgs==1.2.1 mapclassify @ file:///croot/mapclassify_1675157730177/work MarkupSafe @ file:///opt/conda/conda-bld/markupsafe_1654597864307/work matplotlib @ file:///croot/matplotlib-suite_1677674301264/work matplotlib-inline @ file:///opt/conda/conda-bld/matplotlib-inline_1662014470464/work message-filters==4.3.2 mkl-fft==1.3.1 mkl-random @ file:///tmp/build/80754af9/mkl_random_1626186066731/work mkl-service==2.4.0 munch @ file:///Users/ktietz/demo/mc3/conda-bld/munch_1630566382504/work munkres==1.1.4 nav-msgs==4.2.3 networkx @ file:///opt/conda/conda-bld/networkx_1657784097507/work numexpr @ file:///croot/numexpr_1668713893690/work numpy @ file:///croot/numpy_and_numpy_base_1672336185480/work osrf-pycommon==2.0.2 osrm==0.11.3 packaging @ file:///croot/packaging_1671697413597/work pandas==1.5.3 parso @ file:///opt/conda/conda-bld/parso_1641458642106/work pexpect @ file:///tmp/build/80754af9/pexpect_1605563209008/work pickleshare @ file:///tmp/build/80754af9/pickleshare_1606932040724/work Pillow==9.4.0 polyline==2.0.0 pooch @ file:///tmp/build/80754af9/pooch_1623324770023/work prompt-toolkit @ file:///croot/prompt-toolkit_1672387306916/work ptyprocess @ file:///tmp/build/80754af9/ptyprocess_1609355006118/work/dist/ptyprocess-0.7.0-py2.py3-none-any.whl pure-eval @ file:///opt/conda/conda-bld/pure_eval_1646925070566/work pycparser @ file:///tmp/build/80754af9/pycparser_1636541352034/work Pygments @ file:///opt/conda/conda-bld/pygments_1644249106324/work pyOpenSSL @ file:///croot/pyopenssl_1677607685877/work pyparsing @ file:///opt/conda/conda-bld/pyparsing_1661452539315/work pyproj @ file:///tmp/build/80754af9/pyproj_1614276909422/work PySocks @ file:///tmp/build/80754af9/pysocks_1605305812635/work python-dateutil @ file:///tmp/build/80754af9/python-dateutil_1626374649649/work pytz @ file:///croot/pytz_1671697431263/work PyYAML @ file:///croot/pyyaml_1670514731622/work rcl-interfaces==1.2.1 rclpy==3.3.7 rcutils==5.1.2 requests @ file:///opt/conda/conda-bld/requests_1657734628632/work rmw-dds-common==1.6.0 ros2action==0.18.5 ros2bag==0.15.4 ros2cli==0.18.5 ros2component==0.18.5 ros2doctor==0.18.5 ros2interface==0.18.5 ros2launch==0.19.4 ros2lifecycle==0.18.5 ros2multicast==0.18.5 ros2node==0.18.5 ros2param==0.18.5 ros2pkg==0.18.5 ros2run==0.18.5 ros2service==0.18.5 ros2topic==0.18.5 rosbag2-interfaces==0.15.4 rosbag2-py==0.15.4 rosgraph-msgs==1.2.1 rosidl-adapter==3.1.4 rosidl-cli==3.1.4 rosidl-cmake==3.1.4 rosidl-generator-c==3.1.4 rosidl-generator-cpp==3.1.4 rosidl-generator-py==0.14.4 rosidl-parser==3.1.4 rosidl-runtime-py==0.9.3 rosidl-typesupport-c==2.0.0 rosidl-typesupport-cpp==2.0.0 rosidl-typesupport-fastrtps-c==2.2.0 rosidl-typesupport-fastrtps-cpp==2.2.0 rosidl-typesupport-introspection-c==3.1.4 rosidl-typesupport-introspection-cpp==3.1.4 rpyutils==0.2.1 Rtree @ file:///croot/rtree_1675157851263/work scikit-learn @ file:///croot/scikit-learn_1676911643119/work scipy==1.10.0 sensor-msgs==4.2.3 shape-msgs==4.2.3 Shapely @ file:///opt/conda/conda-bld/shapely_1664521582171/work six @ file:///tmp/build/80754af9/six_1644875935023/work sros2==0.10.4 stack-data @ file:///opt/conda/conda-bld/stack_data_1646927590127/work statistics-msgs==1.2.1 std-msgs==4.2.3 std-srvs==4.2.3 stereo-msgs==4.2.3 tf2-geometry-msgs==0.25.2 tf2-kdl==0.25.2 tf2-msgs==0.25.2 tf2-py==0.25.2 tf2-ros-py==0.25.2 tf2-tools==0.25.2 threadpoolctl @ file:///Users/ktietz/demo/mc3/conda-bld/threadpoolctl_1629802263681/work traitlets @ file:///croot/traitlets_1671143879854/work trajectory-msgs==4.2.3 unique-identifier-msgs==2.2.1 urllib3 @ file:///croot/urllib3_1673575502006/work visualization-msgs==4.2.3 wcwidth @ file:///Users/ktietz/demo/mc3/conda-bld/wcwidth_1629357192024/work xyzservices @ file:///croot/xyzservices_1675159059961/work zipp @ file:///croot/zipp_1672387121353/work

Manuel-Oed commented 1 year ago

Ran into the same error. There was some kind of update of the polyline package few months ago. Solved it by installing the version 1.3 of polyline by

pip install --force-reinstall -v "polyline==1.3"

hope it helps

RnoldR commented 1 year ago

Thanks for your suggestion. I tried 1.3 but without succes, even tried version 1.2.1. I noticed that all these version did not have the object 'codec' when I did a dir(polyline). Just curious how your polyline looks.

 >>> import polyline
 >>> dir(polyline)
['__all__', '__builtins__', '__cached__', '__doc__', '__file__', 
'__loader__', '__name__', '__package__', '__path__', '__spec__',
'decode', 'encode', 'polyline']
Manuel-Oed commented 1 year ago

Hmm. Did you run pip install --force-reinstall -v "polyline==1.3" after installing the other packages (or check the version via pip show polyline)? gdal or osrm seems to reinstall polyline to the newest version (on my laptop however) when installing.

For me its

>>> import polyline
>>> dir(polyline)
['PolylineCodec', '__all__', '__builtins__', '__cached__', '__doc__', 
'__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__',
 '__version__', 'codec', 'decode', 'encode']

with

$ pip show polyline
Name: polyline
Version: 1.3
...
RnoldR commented 1 year ago

That solved it!. Thank you manuel-Oed!