I'm currently trying to install the version 0.9.4 of rtree in Python3.7.9. However, I keep getting the following error. Still, I can install any version of rtree>=0.9.5. The problem is that I really need version 0.9.4.
Collecting rtree==0.9.4
Using cached Rtree-0.9.4.tar.gz (62 kB)
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'error'
ERROR: Command errored out with exit status 1:
command: /Users/paulonascimento/Desktop/nooo/pychop3d-master/venv/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/1g/t90pxf4x4rzdypyz5jybl9yw0000gn/T/pip-install-imj0pc0j/rtree_77886c1cf36d47a8aa2bef7aa1b5267f/setup.py'"'"'; __file__='"'"'/private/var/folders/1g/t90pxf4x4rzdypyz5jybl9yw0000gn/T/pip-install-imj0pc0j/rtree_77886c1cf36d47a8aa2bef7aa1b5267f/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/1g/t90pxf4x4rzdypyz5jybl9yw0000gn/T/pip-pip-egg-info-uk6yo3dc
cwd: /private/var/folders/1g/t90pxf4x4rzdypyz5jybl9yw0000gn/T/pip-install-imj0pc0j/rtree_77886c1cf36d47a8aa2bef7aa1b5267f/
Complete output (15 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/1g/t90pxf4x4rzdypyz5jybl9yw0000gn/T/pip-install-imj0pc0j/rtree_77886c1cf36d47a8aa2bef7aa1b5267f/setup.py", line 3, in <module>
import rtree
File "/private/var/folders/1g/t90pxf4x4rzdypyz5jybl9yw0000gn/T/pip-install-imj0pc0j/rtree_77886c1cf36d47a8aa2bef7aa1b5267f/rtree/__init__.py", line 1, in <module>
from .index import Rtree
File "/private/var/folders/1g/t90pxf4x4rzdypyz5jybl9yw0000gn/T/pip-install-imj0pc0j/rtree_77886c1cf36d47a8aa2bef7aa1b5267f/rtree/index.py", line 6, in <module>
from . import core
File "/private/var/folders/1g/t90pxf4x4rzdypyz5jybl9yw0000gn/T/pip-install-imj0pc0j/rtree_77886c1cf36d47a8aa2bef7aa1b5267f/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
----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/56/6f/f1e91001d5ad9fa9bed65875152f5a1c7955c5763168cae309546e6e9fda/Rtree-0.9.4.tar.gz#sha256=cae327e2c03b3da4ea40d0fdf68f3e55fe9f302c56b9f31e1bfeb36dbea73f44 (from https://pypi.org/simple/rtree/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement rtree==0.9.4 (from versions: 0.1.0, 0.2.0, 0.3.0, 0.4, 0.4.1, 0.4.2, 0.4.3, 0.5.0, 0.6.0, 0.7.0, 0.8.0, 0.8.1, 0.8.2, 0.8.3, 0.9.0, 0.9.1, 0.9.2, 0.9.3, 0.9.4, 0.9.5, 0.9.6, 0.9.7)
ERROR: No matching distribution found for rtree==0.9.4
WARNING: You are using pip version 21.3.1; however, version 22.0.4 is available.
You should consider upgrading via the '/Users/paulonascimento/Desktop/nooo/pychop3d-master/venv/bin/python -m pip install --upgrade pip' command.
Most topics on this relate to installing libspatialindex. I've used Homebrew to install spatialindex, but I still can't install rtree==0.9.4. Should I downgrade my Python version or something like that? I also updated my pip version, as suggested in the "WARNING", but the error remains the same.
I had this same issue, only it wasn't when installing but at runtime while importing rtree
on MacOS Ventura 13.6.6. One solution for this if you're not up for building rtree
from scratch yourself is to set the SPATIALINDEX_C_LIBRARY
as documented in this pull request.
You can do it by adding the following code to something like your ~/.zshenv
file or some other way of having that environment variable persist wherever you are using rtree
or things that have it as a dependency like geopandas
:
export SPATIALINDEX_C_LIBRARY=/opt/homebrew/Cellar/spatialindex/1.9.3/lib
This made the above error go away for me.