5

I'm trying to create app using the command python3 manage.py startapp webapp but i'm getting an error that says:

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

So I tried installing sqlite3 using pip install sqlite3 but I got this error:

Using cached sqlite3-99.0.tar.gz

Complete output from command python setup.py egg_info:

Traceback (most recent call last):

File "", line 1, in

File "/tmp/pip-build-dbz_f1ia/sqlite3/setup.py", line 2, in raise RuntimeError("Package 'sqlite3' must not be downloaded from pypi")

RuntimeError: Package 'sqlite3' must not be downloaded from pypi

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-dbz_f1ia/sqlite3/

I tried running this command: sudo apt install sqlite3 but it says sudo is not a valid command, even apt isn't for some reason. I'm running Python3.6.2. I installed Python on my Godaddy hosting and i'm using SSH to install everything. I installed Python and setup a virtualenv. Afterwards, I installed Django and created a Django project. How can I fix these errors to successfully create a Django app?

user2896120
  • 3,180
  • 4
  • 40
  • 100

4 Answers4

2

sqlite3 is part of the standard library. You don't have to install it.

If it's giving you an error, you probably need to install your distribution's python-dev packages, eg with sudo apt-get install python-dev.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
1

I had the same problem. on Windows 10, I have anaconda3-2023.03-1 installation with Python 3.10, and a venv with Python 3.8. sqlite3 worked when run from 'base', but not when run from the virtual environment. The problem was that the sqlite3.exe was missing. I solved it by copying the

 "C:\Users\User\anaconda3\Library\bin\sqlite3.exe"

file to

"C:\Users\User\anaconda3\envs\\{enviroment_name}\Library\bin\sqlite3.exe"
PV8
  • 5,799
  • 7
  • 43
  • 87
viksyn1
  • 11
  • 2
0

as answered by @Daniel Roseman, sqlite3 is part of the standard library since Python v2.5. You don't have to install it.

However, if you have created a virtual environment manually using venv or virtualenv, you would have to copy the sqlite3.dll file directly into the <<environment_name>>\Scripts folder. Worked for me

0

I had the same issue and none of the above answers helped. Having tried several ways and done some research, I've managed to solve it (i.e., to have sqlite3 working in my virtual environment as follows:

  1. I downloaded sqlite-tools from the link: https://sqlite.org/download.html under "Precompiled Binaries for Windows"--> sqlite-tools-win32-x86-3410200.zip
  2. I unzipped the folder, renamed it to sqlite3 (for example), moved it to C:\ (for example).
  3. I added the path of the above-mentioned folder to the Path (Windows -> Environment Variables -> System variables -> Path Edit -> New). SQLite3 in Terminal
Iyad
  • 61
  • 1
  • 6