Python上的libspatialindex和Rtree

15

好的,我正在尝试将libspatialindex安装到我的Ubuntu机器Python上。我按照所有的指示操作,并从http://packages.ubuntu.com/lucid/libspatialindex1下载了 libspatialindex1_1.4.0-1.1_amd64.deb,并选择了与我的64位机器相对应的版本进行安装。我已经安装了它,然后跳转至Rtree python https://pypi.python.org/pypi/Rtree,以在Python中下载并安装Rtree。我按照文件夹内的install.txt文件中给出的安装说明进行操作。它说要通过$ python setup.py install运行本地setup.py。我也这样做了,但此后我得到的是:

`root@ubuntu:/# cd /home/neelabh/Desktop/Rtree
root@ubuntu:/home/neelabh/Desktop/Rtree# python setup.py install
Traceback (most recent call last):
File "setup.py", line 4, in <module>
import rtree
File "/home/neelabh/Desktop/Rtree/rtree/__init__.py", line 1, in <module>
from .index import Rtree
File "/home/neelabh/Desktop/Rtree/rtree/index.py", line 6, in <module>
from . import core
File "/home/neelabh/Desktop/Rtree/rtree/core.py", line 110, in <module>
rt.Error_GetLastErrorNum.restype = ctypes.c_int
File "/usr/lib/python2.7/ctypes/__init__.py", line 378, in __getattr__
func = self.__getitem__(name)
File "/usr/lib/python2.7/ctypes/__init__.py", line 383, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: python: undefined symbol: Error_GetLastErrorNum`

有人能帮我解决这个问题吗!

非常感激!


可能使用了错误的目录? - Has QUIT--Anony-Mousse
2个回答

37
你需要使用系统软件包管理器安装“libspatialindex-dev”软件包。至少在我的系统(Mint 17.1)上是这样的,它应该与默认的Ubuntu安装100%兼容。

谢谢。还有几个库缺失,但问题已经解决了。 - Neelabh Pant
这对我有用,应该被接受为答案! - BigglesZX
也适用于Ubuntu 18.04。谢谢朋友。 - CodeBlooded
还解决了Ubuntu 20.04上的问题。谢谢! - guibar

1
您需要在Ubuntu系统中安装libspatialindex-dev。这里我使用的是Ubuntu 16.04或18.04。
运行以下命令更新软件包列表:sudo apt update 运行以下命令安装libspatialindex-devsudo apt install libspatialindex-dev 使用Python pip版本安装Rtree,我使用的是pip 3.7:pip3.7 install Rtree 导入Rtree:import rtree

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