Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: QGIS Python error "RuntimeError: Cannot find any suitable spatialite module"

  1. #1
    Join Date
    May 2009
    Location
    Spain
    Posts
    28

    Default QGIS Python error "RuntimeError: Cannot find any suitable spatialite module"

    Hi
    I have a problem with QGIS Data Base Administration.
    My system is running Open Suse Leap 15.2, x86 64 bit
    This issue occurs both with QGIS 3.16 and 3.18

    Whenever I try to use the Data Base Administration tool I get a Python error

    The messages window shows the following.

    2021-04-22T22:34:54 WARNING Traceback (most recent call last):
    File "/usr/share/qgis/python/plugins/db_manager/db_model.py", line 456, in rowCount
    self._refreshIndex(parent, True)
    File "/usr/share/qgis/python/plugins/db_manager/db_model.py", line 505, in _refreshIndex
    if item.populate():
    File "/usr/share/qgis/python/plugins/db_manager/db_model.py", line 182, in populate
    if not connection.connect():
    File "/usr/share/qgis/python/plugins/db_manager/db_plugins/spatialite/plugin.py", line 78, in connect
    return self.connectToUri(uri)
    File "/usr/share/qgis/python/plugins/db_manager/db_plugins/plugin.py", line 142, in connectToUri
    self.db = self.databasesFactory(self, uri)
    File "/usr/share/qgis/python/plugins/db_manager/db_plugins/spatialite/plugin.py", line 64, in databasesFactory
    return SLDatabase(connection, uri)
    File "/usr/share/qgis/python/plugins/db_manager/db_plugins/spatialite/plugin.py", line 107, in __init__
    Database.__init__(self, connection, uri)
    File "/usr/share/qgis/python/plugins/db_manager/db_plugins/plugin.py", line 267, in __init__
    self.connector = self.connectorsFactory(uri)
    File "/usr/share/qgis/python/plugins/db_manager/db_plugins/spatialite/plugin.py", line 110, in connectorsFactory
    return SpatiaLiteDBConnector(uri)
    File "/usr/share/qgis/python/plugins/db_manager/db_plugins/spatialite/connector.py", line 51, in __init__
    self.connection = spatialite_connect(self._connectionInfo())
    File "/usr/share/qgis/python/qgis/utils.py", line 684, in spatialite_connect
    raise RuntimeError("Cannot find any suitable spatialite module")
    RuntimeError: Cannot find any suitable spatialite module

    Can anyone help me sort this out.
    BR, Eduardo

  2. #2
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    31,066
    Blog Entries
    15

    Default Re: QGIS Python error "RuntimeError: Cannot find any suitable spatialite module"

    Hi
    Is libspatialite7 installed?
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  3. #3
    Join Date
    May 2009
    Location
    Spain
    Posts
    28

    Default Re: QGIS Python error "RuntimeError: Cannot find any suitable spatialite module"

    Hi
    yes libspatialite7 is installed
    BR

  4. #4
    Join Date
    May 2009
    Location
    Spain
    Posts
    28

    Default Re: QGIS Python error "RuntimeError: Cannot find any suitable spatialite module"

    Forgot to mention I'm running kde

  5. #5
    Join Date
    Oct 2014
    Location
    Rotterdam
    Posts
    281

    Default Re: QGIS Python error "RuntimeError: Cannot find any suitable spatialite module"

    For the record, I am running Tumbleweed and QGIS 3.18.2-Zürich and can start tge DB Manager without problems, but I have no databases configured.

    I see more information is available on https://github.com/qgis/QGIS/issues/42925 and there the comment is "this seems really a local issue... not a QGIS problem."

    I found the source file that is emitting this error, and based on that you see it is searching for:

    Code:
    libs = [
    # SpatiaLite >= 4.2 and Sqlite >= 3.7.17, should work on all platforms
    ("mod_spatialite", "sqlite3_modspatialite_init"),
    # SpatiaLite >= 4.2 and Sqlite < 3.7.17 (Travis)
    ("mod_spatialite.so", "sqlite3_modspatialite_init"),
    # SpatiaLite < 4.2 (linux)
    ("libspatialite.so", "sqlite3_extension_init")
    ]
    Using "sudo zypper se "sudo zypper se spatialite" I see I have libspatialite7 installed but there is also libspatialite (without the 7).

    Do you also have libspatialite7 installed? If not, please install it an retry,
    If you have it installed, you can try to install also libspatialite to see if that makes a difference

    Can you also check the output of following command
    Code:
    > find /usr/share/qgis/python/ -name '*spatialite*' 
    /usr/share/qgis/python/plugins/db_manager/db_plugins/spatialite

  6. #6
    Join Date
    May 2009
    Location
    Spain
    Posts
    28

    Default Re: QGIS Python error "RuntimeError: Cannot find any suitable spatialite module"

    Hi
    here is the output of the command

    Code:
    sudo zypper se spatialite
    Cargando datos del repositorio...
    Leyendo los paquetes instalados...
    
    S  | Name                         | Summary                                                                  | Type
    ---+------------------------------+--------------------------------------------------------------------------+------------
       | libspatialite                | Spatial SQLite                                                           | paquete src
       | libspatialite-debugsource    | Debug sources for package libspatialite                                  | paquete
       | libspatialite-devel          | Development files for libspatialite                                      | paquete
    i+ | libspatialite7               | Spatial SQLite                                                           | paquete
       | libspatialite7-debuginfo     | Debug information for package libspatialite7                             | paquete
       | spatialite-tools             | A collection of Command Line Interface (CLI) tools supporting SpatiaLite | paquete src
       | spatialite-tools             | A collection of Command Line Interface (CLI) tools supporting SpatiaLite | paquete
       | spatialite-tools-debuginfo   | Debug information for package spatialite-tools                           | paquete
       | spatialite-tools-debugsource | Debug sources for package spatialite-tools                               | paquete
    I have libspatialite7 installed but not libspatialite.
    If I try to install it via yast online it doesn't seem to be available, it shows only as source packet.

    The output of the other command you suggest is

    Code:
    find /usr/share/qgis/python/ -name '*spatialite*'
    /usr/share/qgis/python/plugins/db_manager/db_plugins/spatialite

    BR, Eduardo

  7. #7
    Join Date
    May 2009
    Location
    Spain
    Posts
    28

    Default Re: QGIS Python error "RuntimeError: Cannot find any suitable spatialite module"

    I have found where to install spatialite (without 7) from

    https://software.opensuse.org/downlo...%3ALeap%3A15.2

    according to that instruction I should execute
    Code:
    zypper addrepo https://download.opensuse.org/repositories/openSUSE:Leap:15.2/standard/openSUSE:Leap:15.2.repo
    zypper refresh
    zypper install libspatialite
    but that repo doesn't work

    Code:
    sudo zypper addrepo https://download.opensuse.org/repositories/openSUSE:Leap:15.2/standard/openSUSE:Leap:15.2.repo
    No se encuentra el archivo /repositories/openSUSE:Leap:15.2/standard/openSUSE:Leap:15.2.repo en el medio https://download.opensuse.org/
    ¿Cancelar, reintentar o ignorar? [a/r/i/...? mostrar todas las opciones] (a): a
    BR, Eduardo

  8. #8
    Join Date
    Oct 2014
    Location
    Rotterdam
    Posts
    281

    Default Re: QGIS Python error "RuntimeError: Cannot find any suitable spatialite module"

    Okay, you have the same package installed as me running on Tumbleweed.

    I played a bit around.

    With the error mentioning spatialite I found the main Browser menu also has an entry SpatiaLite so I did give that a try and created a test table:


    That was all fine.
    Then I opened up the "DB Manager" and tried to open under "SpatailLite" my newly created test.sqlite and that is triggering the error:



    The stack trace is the same as in the the first post.

    I had a better look at the code, found https://www.sqlite.org/loadext.html and it looks to me it is some sqlite functionality and I think I can reproduce this from the command line using:
    Code:
    > sqlite3
    SQLite version 3.35.5 2021-04-19 18:32:05 
    Enter ".help" for usage hints. 
    Connected to a transient in-memory database. 
    sqlite> select load_extension("libspatialite.so", "sqlite3_extension_init");
    Error: libspatialite.so.so: cannot open shared object file: No such file or directory
    sqlite> select load_extension("mod_spatialite.so", "sqlite3_modspatialite_init");               
    Error: mod_spatialite.so.so: cannot open shared object file: No such file or directory
    sqlite> select load_extension("mod_spatialite", "sqlite3_modspatialite_init"); 
    Error: mod_spatialite.so: cannot open shared object file: No such file or directory
    sqlite> .quit
    
    I see I have both shared objects:

    Code:
    > find /usr -name 'libspatialite*'
    /usr/lib64/libspatialite.so.7
    /usr/lib64/libspatialite.so.7.1.0
    /usr/lib64/qgis/libspatialiteprovider.so
    /usr/share/licenses/libspatialite7
    /usr/share/doc/packages/libspatialite7
    > find /usr -name 'mod_spatialite*'
    /usr/lib64/mod_spatialite.so.7.1.0
    /usr/lib64/mod_spatialite.so.7
    Reading https://www.sqlite.org/loadext.html and found out you can run also "select load_extension" without the second "entry point" and I tried that but same error, so the problem is that sqlite3 can not find these shared objects.

    Code:
    > cat /etc/ld.so.conf 
    /usr/local/lib64 
    /usr/local/lib 
    include /etc/ld.so.conf.d/*.conf 
    # /lib64, /lib, /usr/lib64 and /usr/lib gets added 
    # automatically by ldconfig after parsing this file. 
    # So, they do not need to be listed.
    My libspatialite.so.7 and my mod_spatialite.so.7 are in /usr/lib64/ so that looks good.
    Using strace (a lot of debug output so the interpretation is fuzzy logic) it looks to me sqlite3 is looking for the module name without the .7 at the end

    Code:
    openat(AT_FDCWD, "/usr/lib64/x86_64/mod_spatialite", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) 
    openat(AT_FDCWD, "/usr/lib64/mod_spatialite", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) 
    openat(AT_FDCWD, "/lib64/mod_spatialite.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) 
    openat(AT_FDCWD, "/usr/lib64/mod_spatialite.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
    So that points back again on the availablity of the libspatialite package.

  9. #9
    Join Date
    Oct 2014
    Location
    Rotterdam
    Posts
    281

    Default Re: QGIS Python error "RuntimeError: Cannot find any suitable spatialite module"

    Okay, not sure if the problem is that the libspatialite is not available (also tried on Tumbleweed, "No provider of 'libspatialite' found.")

    On https://tldp.org/HOWTO/Program-Libra...libraries.html I read:

    Thus, /usr/lib/libreadline.so.3 is a fully-qualified soname, which ldconfig would set to be a symbolic link to some realname like /usr/lib/libreadline.so.3.0. There should also be a linker name, /usr/lib/libreadline.so which could be a symbolic link referring to /usr/lib/libreadline.so.3.

    So is the problem that a /usr/lib64/mod_spatialite.so symbolic link to /usr/lib64/mod_spatialite.so.7 is missing?
    I know the install process should do that somehow but I also know how to make symbolic links so:

    Code:
    > sudo ln -s /usr/lib64/mod_spatialite.so.7 /usr/lib64/mod_spatialite.so 
    > sqlite3 
    SQLite version 3.35.5 2021-04-19 18:32:05 
    Enter ".help" for usage hints. 
    Connected to a transient in-memory database. 
    Use ".open FILENAME" to reopen on a persistent database. 
    sqlite> select load_extension("mod_spatialite", "sqlite3_modspatialite_init");  
    sqlite>
    No error anymore so that is a work-around.

    I still think it would be good to fix the root cause. It looks to me that some install script does not set up this symbolic link. That needs more work and some guidance would be helpful.

  10. #10
    Join Date
    May 2009
    Location
    Spain
    Posts
    28

    Default Re: QGIS Python error "RuntimeError: Cannot find any suitable spatialite module"

    Hi Marel

    Creating the symbolic link as you suggested did the trick.
    Now the Data Base Administration window seems to be as it should.
    I hope I can now complete the GIS course.

    I guess it is an installation error as you mention.

    thanks ever so much for your asistance
    BR, Eduardo

    pd: I'm not very familiar with the forum, should I mark the issue as solved and closed?

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •