【问题标题】:How to install libspatialindex on Google Colaboratory如何在 Google Colaboratory 上安装 libspatialindex
【发布时间】:2018-06-25 21:22:53
【问题描述】:

为了使用 Python 高效分析空间数据,我使用了 rtree 空间索引库,依赖于 libspatialindex C 库。

我能够使用 !pip install rtree 在 Google Colaboratory notebook 中成功安装 rtree。

正如预期的那样,这还不够,因为需要首先安装 libspatialindex,正如import rtree 所确认的那样,结果是:

OSError: Could not find libspatialindex_c library file

我不确定是否以及如何在 Google Collaboratory 中安装外部库。在https://github.com/libspatialindex/libspatialindex/wiki/1.-Getting-Started 之后,我设法运行!curl -L http://download.osgeo.org/libspatialindex/spatialindex-src-1.8.5.tar.gz | tar xz,但我没有配置权限: !spatialindex-src-1.8.5/configure

/bin/sh: 1: spatialindex-src-1.8.5/configure: Permission denied

【问题讨论】:

    标签: r-tree google-colaboratory libspatialindex


    【解决方案1】:

    编辑:该错误似乎已修复。构建不再需要下面的!mount ... 命令。我已经相应地更新了the example notebook

    原始响应如下。

    这看起来像一个 Colab 错误。 /content 目录挂载了noexec,这是导致权限错误的原因。

    在修复之前,您可以使用以下命令重新挂载 /content 并获得所需的 exec 权限:

    !mount -o remount,exec /content

    这是安装libspatialindexrtree 的完整笔记本。 https://colab.research.google.com/notebook#fileId=1N7i9zmOwVcUzd4eHWZux4p_WTBMZHi8C

    【讨论】:

    • 感谢您的精彩回复,这很有帮助。一个小的附加问题 - 有没有办法在笔记本之间保持这个安装(这里是合作新手,所以我不确定)。我承认这个后续问题是 OOT
    • 配置它的最简单方法可能是在折叠部分的顶部添加一个单元格,以便在需要时执行安装,例如,colab.research.google.com/…
    • 是的,可以,但是需要很多时间,而且在重复使用笔记本之间似乎没有必要。
    • 嗨,我在修复此错误时遇到问题:SError: 找不到 libspatialindex_c 库文件,我按照此处推荐的笔记本安装该库,但它仍然显示。不得不说这个错误以前没有出现过,我的意思是,我运行一个笔记本没有问题,然后我尝试再次运行它,并且出现了这个错误,现在我还没有摆脱它。欢迎任何建议。
    • 要运行笔记本,您需要指定 RTree 的版本 !pip install "rtree>=0.8,
    猜你喜欢
    • 1970-01-01
    • 2018-06-06
    • 1970-01-01
    • 2020-06-16
    • 1970-01-01
    • 2018-07-09
    • 1970-01-01
    • 2019-05-24
    • 1970-01-01
    相关资源
    最近更新 更多