Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ModuleNotFoundError: No module named '_sqlite3' Error when try to import sqlite3 and Django in Ubuntu

Tags:

python

sqlite

I tried to Create Django Project. I'm able to create project but not able to run the runserver command. I got below error. I also tried to import sqlite3 got same error

>>> import sqlite3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.11/sqlite3/__init__.py", line 57, in <module>
    from sqlite3.dbapi2 import *
  File "/usr/local/lib/python3.11/sqlite3/dbapi2.py", line 27, in <module>
    from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'
>>> 

Python version: Python 3.11.0

like image 776
Muthuraj R Avatar asked Jan 31 '26 00:01

Muthuraj R


1 Answers

This issue is due to python being installed before sqlite3-dev . You need to install sqlite3-dev then reinstall python.

sudo apt install libsqlite3-dev
pyenv install 3.11.3

Source:

https://waylonwalker.com/pyenv-no-sqlite3/

like image 126
PabTorre Avatar answered Feb 01 '26 15:02

PabTorre



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!