6

I continue to have problems setting up a GeoDjango installation that uses Spatialite as a backend on a Windows machine.

I used the GeoDjango installer and downloaded the precompiled libraries from http://www.gaia-gis.it/spatialite/binaries.html, and dumped them into my geodjango/bin directory.

I upgraded my pysqlite2 installation to the newest version, so that extensions can be loaded and I specified SPATIALITE_LIBRARY_PATH in my settings file.

When I run manage syncdb I get the following output

C:\stuff>manage.py syncdb
SpatiaLite version ..: 2.3.1    Supported Extensions:
        - 'VirtualShape'        [direct Shapefile access]
        - 'VirtualText'         [direct CSV/TXT access]
        - 'VirtualNetwork       [Dijkstra shortest path]
        - 'RTree'               [Spatial Index - R*Tree]
        - 'MbrCache'            [Spatial Index - MBR cache]
        - 'VirtualFDO'          [FDO-OGR interoperability]
        - 'SpatiaLite'          [Spatial SQL - OGC]
PROJ.4 Rel. 4.6.1, 21 August 2008
GEOS version 3.0.2-CAPI-1.4.2

However, when setting up the indices for the table I get the following message:

...
Installing custom SQL for core.LocationHint model
updateTableTriggers: "no such module: rtree"
...

I tried to ignore the message, however my models would not save correctly.

I am a little baffled, because the Spatialite library seems to be used and has the "RTree" extension enabled, yet I still get the error message. There is not much information about this error available online; I found the RTree Documentation at sqlite.org/rtree.html, however I was under the impression that it is already included in spatialite because it is listet under "supported extensions".

Do I really need to compile my own sqlite library? Can somebody provide a .dll that already has RTree included? Am I doing something completely wrong? Any help is appreciated, thanks!

4

2 回答 2

1

Hans,spatialite 是 SQLITE3 的扩展。

SQLite3 需要专门用这个选项编译,而且很多时候不需要。例如,mac 上的默认版本不使用 RTREE 编译。但是我认为 sqlite3 应该包括在内,尽管您的 python 安装和 pysqlite 可能使用 sqlite3 的原始版本或其他版本。

您可以尝试 sqlite3.version 来查看 python 正在使用哪个版本。

另请注意,您必须使用正确的配置选项重新安装 pysqlite 模块,即在运行 setup.py install 之前,更改 setup.cfg:

[build_ext]
#define=
include_dirs=PATH_TO_INCLUDE
library_dirs=PATH_TO_LIBS
libraries=sqlite3
#define=SQLITE_OMIT_LOAD_EXTENSION

http://www.gaia-gis.it/spatialite/install-windows.html

于 2009-11-26T12:15:45.907 回答
1

感谢 Issy 为我指明了正确的方向。

问题确实是,pysqlite 创建了一个没有启用 R*TREE 扩展的 sqlite 二进制文件。

我联系了 pysqlite 的开发人员(请参阅链接文本),他们很快回复并告诉我,从 2.5.6 版本开始,“未来的 Windows 二进制文件和编译将默认支持 RTree。”

问题解决了。谢谢大家。

于 2009-11-26T16:20:06.527 回答