在 Macbook Pro M1 蒙特利中安装 rtree==0.9.4

发布于 2025-01-15 19:30:38 字数 3673 浏览 3 评论 0原文

我目前正在尝试在Python3.7.9 中安装rtree 0.9.4 版本。但是,我不断收到以下错误。不过,我可以安装任何版本的 rtree>=0.9.5。问题是我确实需要 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.

大多数主题都与安装 libspatialindex 相关。我已经使用Homebrew安装了spatialindex,但仍然无法安装rtree==0.9.4。我应该降级我的 Python 版本还是类似的东西?我还按照“警告”中的建议更新了我的 pip 版本,但错误仍然相同。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

桃气十足 2025-01-22 19:30:38

我也遇到了同样的问题,只是不是在安装时出现的,而是在 MacOS Ventura 13.6.6 上导入 rtree 时出现的。如果您不准备自己从头开始构建 rtree,一种解决方案是设置 SPATIALINDEX_C_LIBRARY 如本拉取请求中所述

您可以通过将以下代码添加到诸如 ~/.zshenv 文件之类的内容中来实现此目的,或者通过某种其他方式让该环境变量在您使用 rtree 或其他内容时持续存在将其作为像geopandas这样的依赖项:

export SPATIALINDEX_C_LIBRARY=/opt/homebrew/Cellar/spatialindex/1.9.3/lib

这使得上述错误对我来说消失了。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文