Skip to content

Import error: Referencing out of date polyline class #57

@ladoramkershner

Description

@ladoramkershner

As of this commit, from December 2022, this package is referencing an out of date class from polyline. The methods from the PolylineCodec class were moved to be stand alone functions in the refactor. This causes the following error on import

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[5], line 1
----> 1 import osrm
      2 result = osrm.simple_route(
      3                       [21.0566163803209,42.004088575972], [20.9574645547597, 41.5286973392856],
      4                       output='route', overview="full", geometry='wkt')
      6 result[0]['distance']

File [~/miniconda3/envs/geocode/lib/python3.11/site-packages/osrm/__init__.py:53](https://file+.vscode-resource.vscode-cdn.net/Users/ladoramk/repos/geocode/~/miniconda3/envs/geocode/lib/python3.11/site-packages/osrm/__init__.py:53)
     49 RequestConfig = DefaultRequestConfig()
     51 Point = namedtuple("Point", ("longitude", "latitude"))
---> 53 from .core import match, simple_route, nearest, table, trip, _chain
     54 from .extra import AccessIsochrone

File [~/miniconda3/envs/geocode/lib/python3.11/site-packages/osrm/core.py:3](https://file+.vscode-resource.vscode-cdn.net/Users/ladoramk/repos/geocode/~/miniconda3/envs/geocode/lib/python3.11/site-packages/osrm/core.py:3)
      1 # -*- coding: utf-8 -*-
      2 import numpy as np
----> 3 from polyline.codec import PolylineCodec
      4 from polyline import encode as polyline_encode
      5 from pandas import DataFrame

ModuleNotFoundError: No module named 'polyline.codec'

Possible fix would be to replace the import with a try/except import (to be able to support backward compatibility). I am on a Mac and am struggling with of the other dependencies at the moment, but wanted to document!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions