My machine: Linux eyes 4.9.0-9-amd64 #1 SMP Debian 4.9.168-1+deb9u3 (2019-06-16) x86_64 GNU/Linux
i.e. python3.5 is its native python3
Have two python3 in the system:
root@machine: # update-alternatives --list python3
/usr/bin/python3.5
/usr/local/bin/python3.9
root@machine: # update-alternatives --config python3
There are 2 choices for the alternative python3 (providing
/usr/bin/python3).
Selection Path Priority Status
---------------------------------------------------------------
0 /usr/local/bin/python3.9 2 auto mode
1 /usr/bin/python3.5 1 manual mode
* 2 /usr/local/bin/python3.9 2 manual mode
+++++++++++ LET'S CHOOSE 1 FIRST +++++++++++
root@machine: # python3
Python 3.5.3 (default, Nov 18 2020, 21:09:16)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3 <------------ OK
>>> exit()
**+++++++++++ LET'S CHOOSE 2 NOW +++++++++++++
root@machine: # python3
Python 3.9.0 (default, Nov 23 2020, 09:50:01)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.9/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/usr/local/lib/python3.9/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3' <------- WHAT?
>>> exit()
++++++++++++++++++++++++++++++++++++++++++++
root@machine: # head ~/python3-9_distr/Python-3.9.0/config.log
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by python configure 3.9, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ ./configure --enable-optimizations --enable-loadable-sqlite-extensions
++++++++++++++++++++++++++++++++++++++++++++
/usr/lib/python3.5/lib-dynload# ls -la _sqlite3.cpython-35m-x86_64-linux-gnu.so
-rw-r--r-- 1 root root 96552 Nov 18 23:09 _sqlite3.cpython-35m-x86_64-linux-gnu.so
BUT /usr/local/lib/python3.9/lib-dynload DID NOT HAVE _sqlite3.*
I copied _sqlite3.cpython-35m-x86_64-linux-gnu.so and renamed to
-rwxr-xr-x 1 root root 96552 Nov 18 23:09 _sqlite3.cpython-3**9**m-x86_64-linux-gnu.so
Nothing had changed.
++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++
How come ? How can I make sqlite3 work in my python3.9 ?
UPDATE:
I have found a "solution". As I mentioned before, I copied
/var/lib/python3.5/lib-dynload/
_sqlite3.cpython-35m-x86_64-linux-gnu.so
and renamed to
/var/local/lib/python3.9/lib-dynload/
_sqlite3.cpython-39m-x86_64-linux-gnu.so
but it did not work.
Then I copied
_sqlite3.cpython-39m-x86_64-linux-gnu.so
to
_sqlite3.so in the same folder (/var/local/lib/python3.9/lib-dynload/)
It seemed to be working but later I got new problem.
python-x.y-sqlite-z.t
packages. Just installing the last version of sqlite3-dev has no direct impact of making Python able to use it. – Serge Ballesta