Tuesday, May 23, 2017

Trouble installing GeoDjango with spatialite on Python3

Hi,

This is the error message I get when I run "./manage.py test" or "./manage.py migrate":

  File "/home/anthony/nosync/virtualenvs/enhydris3.6/lib/python3.6/site-packages/django/contrib/gis/db/backends/spatialite/base.py", line 53, in get_new_connection                          
    '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.

However, something isn't right. AFAIU pysqlite isn't supported on Python 3, therefore something else is happening. This is a Python 3.6 that I installed on Debian stretch. These are the relevant settings:

DATABASES = {
    'default': {
        'ENGINE': 'django.contrib.gis.db.backends.spatialite',
        'NAME': 'enhydris.db',
    }
}
if os.path.exists('/usr/lib/x86_64-linux-gnu/mod_spatialite.so'):
    # This is necessary for spatialite>=4.2
    SPATIALITE_LIBRARY_PATH = 'mod_spatialite'

Thanks!

A.

--   Antonis Christofides  http://djangodeployment.com

No comments:

Post a Comment