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

panfei cnweike at gmail.com
Wed Jan 20 21:43:50 EST 2021


HI Barry, Thanks for the suggestions, this is my output:

[felix at localhost Downloads]$ gdb /home/felix/.local/python/python-3.9.1/bin/python3
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-120.el7
Copyright (C) 2013 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".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/felix/.local/python/python-3.9.1/bin/python3.9...done.
(gdb) run
Starting program: /home/felix/.local/python/python-3.9.1/bin/python3 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Python 3.9.1 (default, Jan 21 2021, 02:04:50) 
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> 
Program received signal SIGINT, Interrupt.
0x00007ffff6a15983 in __select_nocancel () from /lib64/libc.so.6
Missing separate debuginfos, use: debuginfo-install glibc-2.17-317.el7.x86_64 ncurses-libs-5.9-14.20130511.el7_4.x86_64 nss-softokn-freebl-3.53.1-6.el7_9.x86_64 readline-6.2-11.el7.x86_64 zlib-1.2.7-18.el7.x86_64
(gdb) info shared
>From                To                  Syms Read   Shared Object Library
0x00007ffff7ddbaf0  0x00007ffff7df7060  Yes (*)     /lib64/ld-linux-x86-64.so.2
0x00007ffff78af410  0x00007ffff7a7fd82  Yes         /home/felix/.local/python/python-3.9.1/lib/libpython3.9.so.1.0
0x00007ffff7613e30  0x00007ffff7618cec  Yes (*)     /lib64/libcrypt.so.1
0x00007ffff73fc8f0  0x00007ffff7407db1  Yes (*)     /lib64/libpthread.so.0
0x00007ffff71f3e50  0x00007ffff71f494e  Yes (*)     /lib64/libdl.so.2
0x00007ffff6ff0e90  0x00007ffff6ff17a4  Yes (*)     /lib64/libutil.so.1
0x00007ffff6cf3350  0x00007ffff6d5e316  Yes (*)     /lib64/libm.so.6
0x00007ffff693f9f0  0x00007ffff6a8f9cf  Yes (*)     /lib64/libc.so.6
0x00007ffff671db80  0x00007ffff671e1fb  Yes (*)     /lib64/libfreebl3.so
0x00007fffeffd50b0  0x00007fffeffd6952  Yes         /home/felix/.local/python/python-3.9.1/lib/python3.9/lib-dynload/readline.cpython-39-x86_64-linux-gnu.so
0x00007fffefda0de0  0x00007fffefdbf775  Yes (*)     /lib64/libreadline.so.6
0x00007fffefb6ee40  0x00007fffefb7abb8  Yes (*)     /lib64/libtinfo.so.5
0x00007fffef9557c0  0x00007fffef95c9b2  Yes         /home/felix/.local/python/python-3.9.1/lib/python3.9/lib-dynload/math.cpython-39-x86_64-linux-gnu.so
0x00007fffef6f4cd0  0x00007fffef7080b8  Yes         /home/felix/.local/python/python-3.9.1/lib/python3.9/lib-dynload/_datetime.cpython-39-x86_64-linux-gnu.so
0x00007fffef4e8c40  0x00007fffef4ebd13  Yes         /home/felix/.local/python/python-3.9.1/lib/python3.9/lib-dynload/_heapq.cpython-39-x86_64-linux-gnu.so
0x00007fffef2d7180  0x00007fffef2e08ba  Yes         /home/felix/.local/python/python-3.9.1/lib/python3.9/lib-dynload/_sqlite3.cpython-39-x86_64-linux-gnu.so
0x00007fffeefadf00  0x00007fffef096c00  Yes         /home/felix/.local/sqlite/default/lib/libsqlite3.so.0
0x00007fffeed8b110  0x00007fffeed97698  Yes (*)     /lib64/libz.so.1
(*): Shared library is missing debugging information.
(gdb) 

I created a symbol link to specific version of sqlite3 and set LD_LIBRARY_PATH:

[felix at localhost sqlite]$ ll
total 0
lrwxrwxrwx 1 felix felix  6 Feb 18  2020 default -> latest
lrwxrwxrwx 1 felix felix 13 Jan 20 12:51 latest -> sqlite-3.34.0
drwxrwxr-x 6 felix felix 52 Feb 18  2020 sqlite-3.31.1
drwxrwxr-x 6 felix felix 52 Jan 20 12:51 sqlite-3.34.0
[felix at localhost sqlite]$ pwd
/home/felix/.local/sqlite
[felix at localhost sqlite]$ env | grep LD_
LD_LIBRARY_PATH=/home/felix/.local/mpfr/default/lib/:/home/felix/.local/gmp/default/lib/:/home/felix/.local/mpc/default/lib/:/home/felix/.local/sqlite/default/lib:/home/felix/.local/mysql/default/lib
LD_RUN_PATH=/home/felix/.local/sqlite/default/lib




在 2021年1月21日星期四 UTC+8 上午5:53:38,<Barry Scott> 写道:
> > On 20 Jan 2021, at 19:54, panfei <cnw... 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