Search code examples
pythondjangospatial-indexr-tree

Mac m1, rtree 0.9.7, spatialindex 1.9.3, symbol not found


() isikkaplan@iamhere# python3 manage.py loadfixtures -s=testing fixture fixtures/knock/0_ct.json -v3
Traceback (most recent call last):
  File "/Users/isikkaplan/Desktop/code/---/-/--/manage.py", line 21, in <module>
    main()
  File "/Users/isikkaplan/Desktop/code/---/-/--/manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/site-packages/django/core/management/__init__.py", line 357, in execute
    django.setup()
  File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/site-packages/django/apps/registry.py", line 91, in populate
    app_config = AppConfig.create(entry)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/site-packages/django/apps/config.py", line 90, in create
    module = import_module(entry)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/site-packages/alphashape/__init__.py", line 6, in <module>
    from .alphashape import alphashape
  File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/site-packages/alphashape/alphashape.py", line 15, in <module>
    import geopandas
  File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/site-packages/geopandas/__init__.py", line 1, in <module>
    from geopandas._config import options  # noqa
  File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/site-packages/geopandas/_config.py", line 126, in <module>
    default_value=_default_use_pygeos(),
  File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/site-packages/geopandas/_config.py", line 112, in _default_use_pygeos
    import geopandas._compat as compat
  File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/site-packages/geopandas/_compat.py", line 202, in <module>
    import rtree  # noqa
  File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/site-packages/rtree/__init__.py", line 9, in <module>
    from .index import Rtree, Index  # noqa
  File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/site-packages/rtree/index.py", line 6, in <module>
    from . import core
  File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/site-packages/rtree/core.py", line 77, in <module>
    rt.Error_GetLastErrorNum.restype = ctypes.c_int
  File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/ctypes/__init__.py", line 395, in __getattr__
    func = self.__getitem__(name)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/ctypes/__init__.py", line 400, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: dlsym(RTLD_DEFAULT, Error_GetLastErrorNum): symbol not found

Almost all of the answers online leads to installing spatialindex which I already have and I have no idea how can I fix this.


Solution

  • If you are using a conda environment like I am, which is basically a necessity if you are on an m1 and not using docker, then you need to install the system libraries for the current environment via conda also.

    conda install -c conda-forge libspatialindex