rtree的依赖项缺失

9

我目前正在使用Python的Spyder,当我打开程序时出现以下错误信息:

错误: 您缺少依赖项!

rtree>= 0.8.3: None (NOK)

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

注意: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目前运行良好,我只是不想在后面遇到问题。谢谢!


我猜你可以直接搜索它... 在这里看看:https://gis.stackexchange.com/questions/179706/installing-rtree-on-windows-64-bits。 - Patol75
很遗憾,那个链接没有帮助,但是感谢你的尝试。 - Unicorn_tech
Spyder维护者在此) 通过使用pip在Anaconda中安装/更新Spyder,您基本上破坏了Anaconda,现在您必须完全删除它并重新安装。您还需要删除pip安装软件包的目录,通常为:C:\Users\<your user>\Appdata\Roaming\Python - Carlos Cordoba
你好,Carlos。我已经按照你的建议完成了操作。现在我被告知需要更新它。根据说明,请问确认这样做是否正确?升级Spyder 如果您是通过Anaconda(推荐),WinPython,MacPorts或系统包管理器安装的Spyder,则应使用相同的方法进行更新。 对于Anaconda用户,只需在Anaconda Prompt中运行conda update anaconda以更新整个发行版,conda update spyder以更新Spyder即可。 - Unicorn_tech
你好。我已经通过conda update anaconda更新了anaconda,看起来很成功,但它没有更新Spyder。当我启动程序时仍然会看到警报消息,说我需要下载4.0版本?我可以简单地忽略它吗?还是这会在以后引起问题?我认为尝试手动更新Spyder是让我陷入困境的原因。目前没有rtree错误或内核错误。谢谢。 - Unicorn_tech
8个回答

8

这对我在Spyder 5和Python 3.10中解决了问题。 - Émile Jetzer

6

我也遇到了同样的问题,我不使用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/

找到了一个解决方案,可以通过Homebrew安装spatialindex

brew install spatialindex

然后执行 pipenv install rtree 成功了,现在 geopandas 工作顺畅。希望能对你有所帮助。

我使用了 conda install libspatialindex 然后进行了 pip install rtree,终于成功了。耶! - taranaki

4

我遇到了相同的问题,并尝试了这个页面中展示的所有解决方案。但都失败了。

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

  1. 在base环境下运行anaconda-navigator。
  2. 点击并激活您想要修复的环境。
  3. 在右侧搜索栏中,输入'rtree',您可以看到已安装的'version为0.9.3的'rtree'。
  4. 在名称标签中'rtree'左侧点击小绿色复选框,然后将鼠标光标放在“特定安装掩码”菜单上。
  5. 通过anaconda-navigator点击版本'0.8.3'来降级。

之后,我执行了Spyder,错误消息就消失了。


3

如果您正在使用Anaconda,请执行以下命令:

conda install -c conda-forge rtree=0.9.3

尽管我已经安装了rtree 0.9.7版本,但Spyder无法检测到它。因此我不得不手动将其降级。


2
以下命令解决了我的问题:

conda update --all


它会更新所有已安装的包,解决可能存在的技术问题。

1

我也因同样的问题而来到这里。在我的情况下(Ubuntu2004Python 3.8),当我尝试使用conda install spyder安装spyder 4.2.1时,rtree出现了问题。

然而,当我用conda list rtree检查其安装情况时,它显示version 0.9.7已成功安装。尽管如此,我还是尝试使用pipconda安装rtree包,但都无法解决问题。

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

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

我在没有安装anaconda的Mac上使用了以下步骤:
  1. 选择Python解释器(应该是/usr/local/bin/python3.9)
  2. 安装spatialindex:brew install spatialindex
  3. 安装spyder-kernels:pip install spyder-kernels (参见Python文档)
- Pravu Chaudhary

1
我在更新Linux Mint Anaconda后使用了conda --update all,出现了以下提示信息。当尝试根据推荐方式安装缺失的包时,收到一条消息,称所有必要的依赖项都已安装。
我使用conda list --revisions列出版本修订记录,然后使用conda install --revision N命令,其中N是倒数第二个修订版本,我的情况下是版本10。这解决了问题。问题出在版本11中,其中包含一个新的spyder内核。
请注意,我注意到它包含一个新的Spyder内核。

最终发现通过使用Anaconda Navigator将rtree版本9降级为rtree版本8.3,错误消息消失了。现在可以在Spyder中使用Python 3.8而没有错误消息。 - Never Too Old To Learn

0
我在Mac上使用了以下步骤。我们也可以不使用anaconda来完成:
  1. 选择Python解释器(应该是/usr/local/bin/python3.9)

  2. brew install spatialindex(需要安装Homebrew)

3.pip install spyder-kernels(参考Python文档)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接