2

I am trying to install osmnx library in linux using pip and I get below error.

# pip3 install osmnx
Collecting osmnx
  Using cached osmnx-0.16.1-py2.py3-none-any.whl (87 kB)
Requirement already satisfied: pyproj>=2.6 in /usr/local/lib64/python3.6/site-packages (from osmnx) (2.6.1.post1)
Collecting Rtree>=0.9
  Using cached Rtree-0.9.4.tar.gz (62 kB)
    ERROR: Command errored out with exit status 1:
     command: /bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-_h54goe2/rtree/setup.py'"'"'; __file__='"'"'/tmp/pip-install-_h54goe2/rtree/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-k2qkrb5o
         cwd: /tmp/pip-install-_h54goe2/rtree/
    Complete output (15 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-_h54goe2/rtree/setup.py", line 3, in <module>
        import rtree
      File "/tmp/pip-install-_h54goe2/rtree/rtree/__init__.py", line 1, in <module>
        from .index import Rtree
      File "/tmp/pip-install-_h54goe2/rtree/rtree/index.py", line 6, in <module>
        from . import core
      File "/tmp/pip-install-_h54goe2/rtree/rtree/core.py", line 143, in <module>
        rt.Error_GetLastErrorNum.restype = ctypes.c_int
      File "/usr/lib64/python3.6/ctypes/__init__.py", line 356, in __getattr__
        func = self.__getitem__(name)
      File "/usr/lib64/python3.6/ctypes/__init__.py", line 361, in __getitem__
        func = self._FuncPtr((name_or_ordinal, self))
    AttributeError: /bin/python3: undefined symbol: Error_GetLastErrorNum
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Upon searching and as suggested in several posts I have updated pip and setuptools and installed shapely as well but I get same error. I am trying to install through pip and not conda. Can someone suggest how to resolve this issue and install the library.

mockash
  • 1,204
  • 5
  • 14
  • 26
  • download the rtree wheel from another website, and install rtree from that wheel. then install osmnx again. Also try to install from wheel for any other dependencies which might produce errors. – Atreyagaurav Oct 25 '20 at 10:40
  • 2
    Thanks for your answer. I got it solved by installing `spatialindex` and `rtree` then `osmnx`. – mockash Oct 25 '20 at 10:43
  • 1
    See also https://stackoverflow.com/a/62958055/7321942 – gboeing Oct 25 '20 at 14:46

1 Answers1

2

Below is the process I have followed to overcome this error. Try to upgrade your setuptools.

pip install --upgrade setuptools and if still facing the same issue check if all dependencies of osmnx are installed. In my case I had to do pip install rtree and this was also dependent on spatialindex which I have installed through yum install spatialindex. Then pip install osmnx which worked wonderfully.

Kindly note that spatialindex in ubuntu and debian is libspatialindex-dev.

Also one can follow instructions provided by @gboeing in his answer here.

mockash
  • 1,204
  • 5
  • 14
  • 26