0

I am attempting to install rtree on my macOS machine running python3.7.7. In the geopandas documentation, it indicates that macos installs ddo not include "binary wheels" (not sure what this means honestly) for rtree.

I followed the instructions on the website https://libspatialindex.org/#download and installed the packages using cmake. When I go to my terminal in VScode and run the command python3 -m pip install rtree rtree is downloaded, but it fails to install yielding the error message:

ERROR: Command errored out with exit status 1:
     command: /Library/Frameworks/Python.framework/Versions/3.7/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/12/k00m0tq55399_9bk2svm9zjw0000gn/T/pip-install-ebn0ioj4/rtree/setup.py'"'"'; __file__='"'"'/private/var/folders/12/k00m0tq55399_9bk2svm9zjw0000gn/T/pip-install-ebn0ioj4/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 /private/var/folders/12/k00m0tq55399_9bk2svm9zjw0000gn/T/pip-install-ebn0ioj4/rtree/pip-egg-info
         cwd: /private/var/folders/12/k00m0tq55399_9bk2svm9zjw0000gn/T/pip-install-ebn0ioj4/rtree/
    Complete output (15 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/12/k00m0tq55399_9bk2svm9zjw0000gn/T/pip-install-ebn0ioj4/rtree/setup.py", line 3, in <module>
        import rtree
      File "/private/var/folders/12/k00m0tq55399_9bk2svm9zjw0000gn/T/pip-install-ebn0ioj4/rtree/rtree/__init__.py", line 1, in <module>
        from .index import Rtree
      File "/private/var/folders/12/k00m0tq55399_9bk2svm9zjw0000gn/T/pip-install-ebn0ioj4/rtree/rtree/index.py", line 6, in <module>
        from . import core
      File "/private/var/folders/12/k00m0tq55399_9bk2svm9zjw0000gn/T/pip-install-ebn0ioj4/rtree/rtree/core.py", line 143, in <module>
        rt.Error_GetLastErrorNum.restype = ctypes.c_int
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ctypes/__init__.py", line 377, in __getattr__
        func = self.__getitem__(name)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ctypes/__init__.py", line 382, in __getitem__
        func = self._FuncPtr((name_or_ordinal, self))
    AttributeError: dlsym(RTLD_DEFAULT, Error_GetLastErrorNum): symbol not found
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Steps taken to resolve: - installed postgresql via homebrew as suggested by previous answers to similar questions

I installed the libspacialindex stuff in the same directory as my project. Is this where the problem is? Am I missing some crucial package needed for this?

Any help is greatly appreciated, let me know if you require more info.

  • related: https://stackoverflow.com/questions/60634470/python-error-while-i-try-to-update-pysal – Lorinczy Zsigmond Apr 28 '20 at 06:52
  • If you can, install GeoPandas and all its dependencies using conda from conda-forge. https://geopandas.readthedocs.io/en/latest/install.html#using-the-conda-forge-channel That will take care of all these C dependencies. – martinfleis Apr 28 '20 at 07:45
  • @martinfleis is correct, installing the most recent version of anaconda solved all of this. Thank you. – dataScience Apr 28 '20 at 17:18

1 Answers1

0

First install spatialindex via brew, then rtree via pip:

brew install spatialindex

pip install rtree
Christoph Rieke
  • 707
  • 5
  • 7