sqlite3 cannot detect the version of compiled sqlite version at some point in runtime.

Barry Scott barry at barrys-emacs.org
Wed Jan 20 16:53:16 EST 2021



> On 20 Jan 2021, at 19:54, panfei <cnweike at gmail.com> wrote:
> 
> System environment:
> 
> Cent OS 7
> Sqlite3 3.34.0 (Compile from source)
> Python 3.9.1 (Compile from source)
> Django 3.1.5 (Pip install)
> 
> 
> 1. Compile sqlite3:
> ./configure --prefix=/home/felix/.local/sqlite/sqlite-3.34.0
> make && make install
> 
> 2. Add sqlite3 lib to lib search path:
> 
> export LD_LIBRARY_PATH=/home/felix/.local/sqlite/sqlite-3.34.0/lib
> export LD_RUN_PATH=/home/felix/.local/sqlite/sqlite-3.34.0/lib
> 
> 3. Compile Python 3.9.1
> C_INCLUDE_PATH=/home/felix/.local/sqlite/sqlite-3.34.0/include/ CPLUS_INCLUDE_PATH=/home/felix/.local/sqlite/sqlite-3.34.0/include/ LD_RUN_PATH=/home/felix/.local/sqlite/default/lib ./configure --prefix=/home/felix/.local/python/python-3.9.1 --enable-optimizations
> make && make install
> 
> 4. Test sqlite3
> Python 3.9.1 (default, Jan 20 2021, 14:32:50)
> [GCC 10.2.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import sqlite3
>>>> conn = sqlite3.connect(':memory:')
>>>> conn.create_function('f', 2, lambda *args: None, deterministic=True)
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
> sqlite3.NotSupportedError: deterministic=True requires SQLite 3.8.3 or higher
>>>> sqlite3.sqlite_version
> '3.34.0'
>>>> sqlite3.version
> '2.6.0'
>>>> 
> 
> It reports "deterministic=True requires SQLite 3.8.3 or higher", but when execute sqlite3.sqlite_version it returns 3.34.0 which higher than 3.8.3.
> 
> Is there any advice on this issue? thanks.

My guess is that at runtime the systems old sqlite3 is used and not your new one.
is LD_LIBRARY_PATH setup correctly when you run python3.9?

You can check this by doing the following:

$ gdb python3.9
(gdb) run
>>> import sqlite3
Ctrl-C
(gdb) info shared

Below is that I get on a Fedora 33 system by way of example output:

$ gdb python3.9
GNU gdb (GDB) Fedora 10.1-2.fc33
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from python3.9...
Reading symbols from .gnu_debugdata for /usr/bin/python3.9...
(No debugging symbols found in .gnu_debugdata for /usr/bin/python3.9)
Missing separate debuginfos, use: dnf debuginfo-install python3-3.9.1-1.fc33.x86_64
(gdb) run
Starting program: /usr/bin/python3.9 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Python 3.9.1 (default, Dec  8 2020, 00:00:00) 
[GCC 10.2.1 20201125 (Red Hat 10.2.1-9)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> 
Program received signal SIGINT, Interrupt.
0x00007ffff7b7ff4a in select () from /lib64/libc.so.6
(gdb) i sh
From                To                  Syms Read   Shared Object Library
0x00007ffff7fd2090  0x00007ffff7ff2f96  Yes (*)     /lib64/ld-linux-x86-64.so.2
0x00007ffff7caed30  0x00007ffff7e58c7d  Yes (*)     /lib64/libpython3.9.so.1.0
0x00007ffff7aad690  0x00007ffff7bfa69d  Yes (*)     /lib64/libc.so.6
0x00007ffff7a6ca90  0x00007ffff7a7b125  Yes (*)     /lib64/libpthread.so.0
0x00007ffff7a60270  0x00007ffff7a611c9  Yes (*)     /lib64/libdl.so.2
0x00007ffff7a5a3f0  0x00007ffff7a5adb0  Yes (*)     /lib64/libutil.so.1
0x00007ffff79223d0  0x00007ffff79bd718  Yes (*)     /lib64/libm.so.6
0x00007ffff7fbca50  0x00007ffff7fbe310  Yes (*)     /usr/lib64/python3.9/lib-dynload/readline.cpython-39-x86_64-linux-gnu.so
0x00007fffea1dc270  0x00007fffea204587  Yes (*)     /lib64/libreadline.so.8
0x00007fffea1a3470  0x00007fffea1afb8c  Yes (*)     /lib64/libtinfo.so.6
0x00007fffea22ba70  0x00007fffea2316ef  Yes (*)     /usr/lib64/python3.9/lib-dynload/math.cpython-39-x86_64-linux-gnu.so
0x00007fffea13ead0  0x00007fffea149d8c  Yes (*)     /usr/lib64/python3.9/lib-dynload/_datetime.cpython-39-x86_64-linux-gnu.so
0x00007ffff7fb2170  0x00007ffff7fb318b  Yes (*)     /usr/lib64/python3.9/lib-dynload/_heapq.cpython-39-x86_64-linux-gnu.so
0x00007fffea128510  0x00007fffea1308ee  Yes (*)     /usr/lib64/python3.9/lib-dynload/_sqlite3.cpython-39-x86_64-linux-gnu.so
0x00007fffe9fd79b0  0x00007fffea0c7024  Yes (*)     /lib64/libsqlite3.so.0
0x00007fffe9fb05f0  0x00007fffe9fbdb2b  Yes (*)     /lib64/libz.so.1
(*): Shared library is missing debugging information.
(gdb) 

You can see that the python module is:
     /usr/lib64/python3.9/lib-dynload/_sqlite3.cpython-39-x86_64-linux-gnu.so

and that libsqlite3 comes from:
    /lib64/libsqlite3.so.0

Barry



> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 



More information about the Python-list mailing list