Python:pysqlite 库不支持 C 扩展加载

reb*_*ard 5 python sqlite django postgis spatialite

我正在尝试让 Spatialite 与我的 django 应用程序一起使用,但是,我遇到了以下问题:

 raise ImproperlyConfigured('The pysqlite library does not support C extension loading. '
django.core.exceptions.ImproperlyConfigured: The pysqlite library does not support C extension loading. Both SQLite and pysqlite must be configured to allow the loading of extensions to use SpatiaLite.
make: *** [syncdb] Error 1
Run Code Online (Sandbox Code Playgroud)

使用 ubuntu 12.04,我已经安装了 pysqlite pip,在同一个用户中使用 sudo。我也尝试过编译 pysqlite 并启用扩展加载自己。

帮助?

Bra*_*rds 4

pysqlite 的默认设置是在不支持扩展加载的情况下构建。所以仅仅重建是没有帮助的。您需要更改设置(在 setup.cfg 中)。

所以我建议下载为 tarball,并查看 setup.cfg:

[build_ext]
#define=
#include_dirs=/usr/local/include
#library_dirs=/usr/local/lib
libraries=sqlite3
define=SQLITE_OMIT_LOAD_EXTENSION
Run Code Online (Sandbox Code Playgroud)

最后一行就是问题所在。最简单的方法是将其注释掉(在行首添加 #),因此它看起来像:

[build_ext]
#define=
#include_dirs=/usr/local/include
#library_dirs=/usr/local/lib
libraries=sqlite3
# define=SQLITE_OMIT_LOAD_EXTENSION
Run Code Online (Sandbox Code Playgroud)

然后根据 tarball 中的说明重建(请参阅 doc/install-source.txt)