Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: The pysqlite library does not support C extension loading

I'm trying to get Spatialite to work with my django app, however, I've hit the following wall:

 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

Using ubuntu 12.04, I have installed pysqlite using pip within the same user and with sudo. I have also tried compiling pysqlite and enabled extension loading myself.

Help?

like image 731
rebelliard Avatar asked Oct 08 '22 11:10

rebelliard


1 Answers

The default for pysqlite is to build without extension loading support. So just rebuilding won't help. You need to change a setting (in setup.cfg).

So I'd suggest downloading as a tarball, and looking in setup.cfg:

[build_ext]
#define=
#include_dirs=/usr/local/include
#library_dirs=/usr/local/lib
libraries=sqlite3
define=SQLITE_OMIT_LOAD_EXTENSION

That last line is the problem. The easiest way is just to comment it out (add a # at the start of the line), so it looks like:

[build_ext]
#define=
#include_dirs=/usr/local/include
#library_dirs=/usr/local/lib
libraries=sqlite3
# define=SQLITE_OMIT_LOAD_EXTENSION

Then rebuild according to the instructions in the tarball (see doc/install-source.txt)

like image 96
BradHards Avatar answered Oct 13 '22 11:10

BradHards