How to resolve No module named _sqlite3 when I create Django application?

6.6k views Asked by At

I have installed python version 3.4 on CentOS 2.6

and I also installed Django 1.8.

Then I try to create Django application like below.

$django-admin.py startproject mysite

$cd mysite
$python3 manage.py startapp poll

I got some error. How can I overcome this situation. Thanks in advance.

Traceback (most recent call last):
File "/usr/local/lib/python3.4/site-packages/django/db/backends/sqlite3/base.py", line 31, in <module>
from pysqlite2 import dbapi2 as Database
ImportError: No module named 'pysqlite2'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/django/db/backends/sqlite3/base.py", line 33, in <module>
from sqlite3 import dbapi2 as Database
...
ImportError: No module named '_sqlite3'

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
...
raise ImproperlyConfigured("Error loading either pysqlite2 or sqlite3 modules (tried in that order): %s" % exc)
django.core.exceptions.ImproperlyConfigured: Error loading either pysqlite2 or sqlite3 modules (tried in that order): No module named '_sqlite3'
2

There are 2 answers

0
Fernando Esteves On

I appended "PYTHONVERSION=3.5" just below line "VERSION=3.5" in the Makefile and recompiled. It worked.

0
yanik On

runing sudo apt-get install python-sqlite does the trick for me