skip to content
Notes && Anecdotes
A decorative, semi-related stock photo that adds less value than this comment.

No module named '_sqlite3'

debuggingdjangopythonpython3sqlite

TLDR

Exception kept happening on a debian server. I fixed it with:

sudo apt-get install python-dev
sudo apt-get install libsqlite3-dev

And recompile python (see own post)

Long version

So, I was starting a django app (1.7.1 with Python 3.4),

python manage.py migrate

when i encountered

django.core.exceptions.ImproperlyConfigured:
Error loading either pysqlite2 or sqlite3 modules (tried in that order):
No module named '\_sqlite3'

Did not expect this. I have heard rumers that sqlite3 has been included with python for quite some time. But OK. Let’s install it

pip3.4 install pysqlite

That should fix it, yep? Nope.

File "/home/tomas/optimaltrener/env/build/pysqlite/setup.py", line 85

print "Is sphinx installed? If not, try 'sudo easy_install sphinx'."

So the pysqlite does not support Python3+ (since its using that old syntax)? huh. Googling around said Python3+ (and earlier) should already be delivered with an appropriate sqlite3. But that didn’t seem to do it. But i found this and this, which lead me to

sudo apt-get install libsqlite3-dev
sudo apt-get install python-dev

Followed by recompiling python3.4 (see own post), which fixed everything.

Finally :D