缺少rtree的依赖关系

时间:2020-01-30 08:39:41

标签: python spyder

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

rtree> = 0.8.3:无(否)

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

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

我尝试通过pip安装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的运行情况非常好,我只是不想在此过程中遇到任何问题。谢谢!

6 个答案:

答案 0 :(得分:6)

看起来Rtree需要libspatialindex(https://libspatialindex.org),该文件不会自动安装。似乎有些开发人员已经意识到了这个问题,并着手进行修复:

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

答案 1 :(得分:4)

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

找到了solution-通过Homebrew安装spatialindex

brew install spatialindex

然后pipenv install rtree成功了,现在geopandas正常运行了
希望能帮上忙

答案 2 :(得分:4)

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

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

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

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

答案 3 :(得分:1)

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

然而,当我用 conda list rtree 检查它的安装时。它已显示成功安装 version 0.9.7。尽管如此,我还尝试使用 rtreepip 安装 conda 软件包。没有一个成功。

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

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

答案 4 :(得分:1)

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

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

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

答案 5 :(得分:1)

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

session_start();

// Included for clarity - this would typically be in a config
define('CSRFTOKEN', '__csrftoken');

$root_domain = $_SERVER['HTTP_HOST'] ?? false;
$referrer = parse_url($_SERVER['HTTP_REFERER'] ?? '', PHP_URL_HOST);

// Check submission was from same origin
if ($root_domain !== $referrer) {
    // Invalid attempt
    die();
}

// Extract and validate token
$token = $_POST[CSRFTOKEN] ?? false;
$sessionToken = $_SESSION[CSRFTOKEN] ?? false;
if (!empty($token) && $token === $sessionToken) {
  // Request is valid so process it
}

// Invalidate the token  
$_SESSION[CSRFTOKEN] = false;
unset($_SESSION[CSRFTOKEN]);

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