缺少 rtree 的依赖项

Uni*_*ech 9 python spyder

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

rtree>= 0.8.3:无(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.
Run Code Online (Sandbox Code Playgroud)

请指教我能做什么。到目前为止,Spyder 工作得很好,我只是不想在此过程中遇到问题。谢谢!

小智 7

看起来 Rtree 需要未自动安装的libspatialindex ( https://libspatialindex.org )。似乎一些开发人员意识到了这个问题并正在着手修复:

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


Den*_*nis 6

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

# 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/
Run Code Online (Sandbox Code Playgroud)

找到解决方案-spatialindex通过 Homebrew安装:

brew install spatialindex
Run Code Online (Sandbox Code Playgroud)

然后pipenv install rtree成功了,现在geopandas工作顺利
希望它会有所帮助