I clicked on its official link at the Django doc and it led me to a confusing site. How do I navigate it?
» pip install db-sqlite3
Hello, world.
I've just bought a new Ubuntu 16.04 server and I want to host some programs. I use sqlite3 module in all my programs. I compiled last version of Python, Python 3.6, from sources but when I try to import sqlite3 I have this error:
>>> import sqlite3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/usr/local/lib/python3.6/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'I have tried to recompile Python with --enable-loadable-sqlite-extensions argument, I have installed sqlite3 cli, I have done ALL things found in internet, and I lose 4 hours of my time. Thanks for help.
EDIT: SQLite is working fine on Python 2.x
That error means that you didn't have the SQLite development package installed when you built Python. The sqlite3 binary CLI program is totally irrelevant; Python does not use that, and its presence does not mean you have the correct package installed. The necessary package is libsqlite3-dev. You don't need --enable-loadable-sqlite-extensions.
Isn't Python 3.6 available from your package manager?
The module is named sqlite3, not sqlite.
sqlite3 is built into Python's standard library (https://docs.python.org/3/library/sqlite3.html), you should not try to install it using pip.
If import sqlite3 does not work either, it means you've compiled Python without SQLite support, and you need to build it again after installing the libsqlite3-dev package.
Had same issue after compiling python 3.12 with default make command on Debian. Returns error while import sqlite3
ModuleNotFoundError: No module named '_sqlite3'
After installing libsqlite3-dev, issue got resolved
./configure --enable-loadable-sqlite-extensions && make altinstall
» pip install pysqlite3
» pip install sqlite-database