I am trying to use Midvatten on QGIS 2.18.13 on a mac. When I create a new database, I get

"no such function: spatialite_version" (see error message below).

I've uninstalled and reinstalled QGIS (using Kyngchaos's packages) and Midvatten. None of that has helped.

How do I get this basic spatialite function working?

Traceback (most recent call last):

File "/Users/Becca/.qgis2/python/plugins/midvatten/midvatten.py", line 853, in new_db newdbinstance = newdb(verno)

File "/Users/Becca/.qgis2/python/plugins/midvatten/tools/create_db.py", line 41, in init self.create_new_db(verno,user_select_CRS,EPSG_code, delete_srids) #CreateNewDB(verno)

File "/Users/Becca/.qgis2/python/plugins/midvatten/tools/create_db.py", line 82, in create_new_db versionstext = self.cur.execute('select spatialite_version()').fetchall()

OperationalError: no such function: spatialite_version


1 Answer 1


Have you installed the KyngChaos SQLite Framework ?

It contains Spatialite and pyspatialite

In Python

import pyspatialite
# location of the pyspatialite module

The error comes from the line 82 of your create_db.py file (versionstext = self.cur.execute('select spatialite_version()').fetchall(): OperationalError: no such function: spatialite_version) and with a correct installation, it works without problem.

from pyspatialite import dbapi2 as sqlite  # line 30 
conn = sqlite.connect("Midv.sqlite")
cur = conn.cursor()
print cur.execute('select spatialite_version()').fetchall() #line 82
  • I am using the Kyngchaos Sqlite Framework. The pyspatialite file is in the right place but still I get the no such function: spatialite_version error. I tried to just set the version in create_db.py but then got a series of errors about not being able to create some (but not all) of the standard tables.
    – Becca
    Oct 24, 2017 at 22:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.