SQLite3 is a lightweight database engine that is available as a part of the Python Standard Library. It acts as local database. Therefore makes it very fast and reliable. If you are building small applications then SQLite3 is the best framework as it is a lightweight database engine. However, sometimes you can get errors like Modulenotfounderror: no module named ‘_sqlite3’.
If you are getting then this post is for you. In this tutorial, you will learn how to solve this error.
What is ModuleNotFoundError?
The “ModuleNotFoundError” is an exception error that is raised when a Python program is unable to find a module that it requires. It can happen for a number of reasons, but the most common reason is that the module you’re trying to use simply doesn’t exist in your system. For example, if you are importing the module “x” then you will get the error Modulenotfounderror: no module named ‘x’ if the python interpreter does not find the module x in your system.
Why does the Modulenotfounderror: no module named ‘_sqlite3’ occurs ?
There can be many reasons for getting the error No module named ‘_sqlite3’ but the most common reason is that the SQLite library must not be installed on your system.
If you are a Windows user, you can download the SQLite3 library from the official website. And If you are a Mac user, you can install the SQLite library using Homebrew.
You will get the following error when you will use the SQLite module in your python code.
Modulenotfounderror: no module named '_sqlite3' occurs
Solution of the no module named ‘_sqlite3’ Error
To solve this error you have to install the db-sqlite3 module in your system. To install it you have to check the version of python. If the version of the python is 3. xx then use pip3 and if it is python 2. xx then use the pip command.
Python 3. xx
pip3 install db-sqlite3
pip install db-sqlite3
After that, if you try to use the sqlite3 code in your python code then you will not get the error.
But even If you’re still getting the “no module named ‘_sqlite3′” error, then you have to check the PYTHONPATH variable. The PYTHONPATH variable contains the list of directories that Python.
To check your PYTHONPATH variable, open your terminal window or command prompt and run the following command:
You will get the path for all the python modules installed in your system. You have to set the Python path for the sqlite3 module. Run the following command to add the
It will solve the Modulenotfounderror: no module named ‘_sqlite3’ error.
SQLite3 is lightweight database API that is very useful if you want to make a prototype of an application or are using small applications. If you are getting the Modulenotfounderror: no module named ‘_sqlite3’ error then the above method will solve this error.