As explained here : https://gis.stackexchange.com/a/277071/20802 the standard Python framework on Mac OS X is not compile with the load extension function. Therefore it is impossible to use sql queries with this package and within QGIS (2.18 or 3.0) on Mac OSx.

The kyngchaos version of QGIS is compile to work with the standard version of Python (http://www.kyngchaos.com/software/qgis) but as this problem arise could someone tell me how to point out the pip version of Python to QGIS rather than the standard one? Or any other solution

https://gis.stackexchange.com/users/55203/steven-kay gave a link to an older topic which might was working with older python version. but wasn't successful with Python 3.6

It's not just a Mac OS X problem (Red Hat Bug 1066708 - Python sqlite3 module does not allow the loading of extensions (should be enabled), Anaconda sqlite not compiled with load extension capability, special python library needed for spatialite?, Problem loading spatialite extension with sqlite3 Python connector or Using pysqlite2 instead of sqlite3 when needed and many others)

For the Python version 2.7.x pre-installed by Apple (used by the Kyng Chaos QGIS 2.x versions), you can use the pysqlite module. The KyngChaos version of pyspatialite uses pysqlite and not sqlite3

import pyspatialite
pyspatialite.__file__
'/Library/Frameworks/SQLite3.framework/Versions/C/Python/2.7/pyspatialite/__init__.pyc'
import pysqlite2
pysqlite2.__file__
'/Library/Frameworks/SQLite3.framework/Versions/C/Python/2.7/pysqlite2/__init__.pyc'

For the QGIS 3.x version, Kyng Chaos specifies that you must install the python.org Python 3.6

  • It works before QGIS 2.18 I think I remember. But not since that. I know that 3.x version of QGIS Kyng Chaos specified this, this is exactly the problem – Arthur Apr 23 at 17:03
  • I have also an Unbutu running on my machine, and QGIS on this works perfectly fine with sql and python. – Arthur Apr 24 at 8:04

I recommend trying the latest version of QGIS for OS X, 3.0.3; the installer is now available directly from qgis.org and depends not on the OS X python but the official python.org distribution of 3.6. This should install more smoothly now for you.

  • That doesn't change anything to the problem, which is the official python disctribution coming without load extension enabled. – Arthur Jun 13 at 7:30

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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