ModuleNotFoundError: No module named '_sqlite3'

Hi,
I am a django beginner, did the installation following the documentation, started a project and when I executed the command python manage.py runserver, the output in the terminal was (ModuleNotFoundError: No module named ‘_sqlite3’), how do I solve it?

I have 2 questions:

  1. What operating system are you using (e.g. Windows, Linux, Mac)?

  2. How did you install Python?

-Jorge

Hi jlgimeno.

I’m using :

  • OS : Linux Debian 9 Stretch
  • Python Version : 3.7.3

Did you build Python 3.7.3 from source?

I installed it through the directory : apt-repository ppa: deadsnakes/ppa

What is happening is that your Python installation did not install sqlite. On many linux distributions, the Python package does not include what is needed to build some external tools. Sqlite happens to be one of them.

There’s two ways to solve this: The first I have done, the second I found as an alternative.

  1. First is to install sqlite while building Python from source. I have this bookmarked here, as I build from source whenever I install a new Python version: https://solarianprogrammer.com/2017/06/30/building-python-ubuntu-wsl-debian/

  2. I have not tried this, but I found this for Python 3: https://github.com/coleifer/pysqlite3. There’s a prebuilt binary wheel for linux that might work for you.

Let me know how it goes!

-Jorge

Thanks @jlgimeno . I have Fedora and the first way helped me.
I needed to install sqlite-devel before comiling Python 3.7

dnf install sqlite-devel
1 Like

@horvatha hello i installed the sqlite-devel … so pls how to recompile python 3.8 … am using fedora 35

This isn’t a Django issue - you might find more useful information either in a Fedora forum or a Python forum.