Django - No module named _sqlite3
You may also have compiled python by hand with no sqlite development library installed
So, do
sudo apt-get install libsqlite3-dev libsqlite3
Then, re-install python
test by entering
python
>>> import sqlite3
At the django.db.backends.sqlite3, it tries to
try:
try:
from pysqlite2 import dbapi2 as Database
except ImportError:
from sqlite3 import dbapi2 as Database
except ImportError as exc:
from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured("Error loading either pysqlite2 or sqlite3 modules (tried in that order): %s" % exc)
So one of the modules named sqlite3 or pysqlite2 is not installed. Try to install them
$ pip install sqlite3 # or pysqlite2
Update
sqlite3
and pysqlite2
are part of Python, therefore these two packages are not in PyPi anymore.
I got very similar error message when I tried to run the Django development server:
ImproperlyConfigured: Error loading either pysqlite2 or sqlite3 modules (tried in that order): dlopen(/Users/Rubinous/Projects/Jiiri2/jiiri_venv/lib/python2.7/lib-dynload/_sqlite3.so, 2): Library not loaded: /usr/local/opt/sqlite/lib/libsqlite3.0.8.6.dylib
Referenced from: /Users/Rubinous/Projects/Jiiri2/jiiri_venv/lib/python2.7/lib-dynload/_sqlite3.so
Reason: image not found
I solved this by installing pysqlite
Python module with pip install pysqlite
.