缺少树的依赖项

Missing dependancies of rtree

我目前正在为 Python 使用 Spyder,当我打开程序时出现以下错误消息: 错误: 您缺少依赖项!

rtree>=0.8.3:None(挪威克朗)

请安装它们以避免出现此消息。

注意:Spyder 可以在没有这些依赖项的情况下工作,但是为了获得流畅的体验,我们强烈建议。

我试过 pip install rtree 并得到:

Collecting rtree
  Downloading https://files.pythonhosted.org/packages/11/1d/42d6904a436076df813d1df632575529991005b33aa82f169f01750e39e4/Rtree-0.9.3.tar.gz (520kB)
     |████████████████████████████████| 522kB 467kB/s
    ERROR: Command errored out with exit status 1:
     command: 'C:\Users\gitte\Anaconda3\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\gitte\AppData\Local\Temp\pip-install-kmbt5h2t\rtree\setup.py'"'"'; __file__='"'"'C:\Users\gitte\AppData\Local\Temp\pip-install-kmbt5h2t\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 pip-egg-info
         cwd: C:\Users\gitte\AppData\Local\Temp\pip-install-kmbt5h2t\rtree\
    Complete output (11 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\gitte\AppData\Local\Temp\pip-install-kmbt5h2t\rtree\setup.py", line 3, in <module>
        import rtree
      File "C:\Users\gitte\AppData\Local\Temp\pip-install-kmbt5h2t\rtree\rtree\__init__.py", line 1, in <module>
        from .index import Rtree
      File "C:\Users\gitte\AppData\Local\Temp\pip-install-kmbt5h2t\rtree\rtree\index.py", line 6, in <module>
        from . import core
      File "C:\Users\gitte\AppData\Local\Temp\pip-install-kmbt5h2t\rtree\rtree\core.py", line 128, in <module>
        raise OSError("could not find or load %s" % lib_name)
    OSError: could not find or load spatialindex_c-64.dll
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

请指教我能做什么。到目前为止,Spyder 运行良好,我只是不想在此过程中出现问题。谢谢!

看起来 Rtree 需要 libspatialindex (https://libspatialindex.org),它不会自动安装。似乎一些开发人员已经意识到这个问题并正在修复:

https://github.com/Toblerity/rtree/issues/146 https://github.com/Toblerity/rtree/issues/147

来到这里遇到同样的问题,我不使用 conda 并且无法使用 pipenv 安装 libspatialindex:

# macOS Mojave 10.14.5
# python 3.7.4 (via pyenv)

Error: Command "python setup.py egg_info" failed with error code 1 in /var/folders/r7/2sx1wsvx0gj5x43wkmymg61w0000gq/T/tmpn09357tzbuild/rtree/

找到 solution — 通过 Homebrew 安装 spatialindex

brew install spatialindex

然后pipenv install rtree成功,现在geopandas工作顺利
希望对你有帮助

我也遇到了同样的问题。就我而言(Ubuntu2004Python 3.8),当我尝试使用 conda install spyder 安装 spyder 4.2.1 时,rtree 的问题仍然存在。

然而,当我用conda list rtree检查它的安装时。它显示 version 0.9.7 已成功安装。尽管如此,我也尝试安装 rtree 包,同时包含 pipconda。 None 已经解决了。

后来,我尝试了不同的安装命令(基本上是不同的conda通道),然后,这个问题就消失了。注意下面使用conda-forge渠道下载spyder。

conda create --name spy42py38 python==3.8
conda install spyder=4.2.1 -c conda-forge

我在用 conda --update all 更新 linux mint anaconda 后收到此消息。当安装丢失包的建议方法给出一条消息,表明所有必要的依赖项都已安装。

我使用 conda list --revisions 来列出修订,然后是 conda install --revision N,其中 N 是倒数第二个修订,在我的例子中是修订 10。这解决了问题。修订版 11 是罪魁祸首。

我注意到它包含一个新的 spyder 内核。

我遇到了同样的问题并尝试了此页面中显示的所有解决方案。但是失败了。

最后,我找到了解决方案...

  1. 运行 基地的蟒蛇导航器
  2. 单击并激活您要修复的环境
  3. 在右边的搜索栏输入'rtree',可以看到安装的'rtree',版本可能是0.9.3。
  4. 在“名称”选项卡中单击 'rtree' 左侧的绿色小复选框,然后将鼠标光标放在 'mask for specific installation' 菜单上。
  5. 点击版本“0.8.3”通过 anaconda-navigator 降级。

之后,我执行了spyder,错误信息消失了。

如果您使用的是Anaconda,请执行以下命令:

conda install -c conda-forge rtree=0.9.3

虽然我有 rtree 版本 0.9.7,但 Spyder 无法检测到它。所以我不得不手动降级它。

我对 mac 使用了以下步骤。我们也可以在没有 anaconda 的情况下做到这一点:

  1. select python 解释器(应该是/usr/local/bin/python3.9)

  2. brew install spatialindex(应该安装 homebrew)

3.pip 安装 spyder-kernels(参考 python 文档)

以下命令为我解决了这个问题:

conda 更新 --all