0

failed to run django for lack of sqlite? in fact sqlite is already install in my system.

(py1)[mirror@home ci]$ python manage.py runserver
Validating models...

Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x9ea3d8c>>
Traceback (most recent call last):
  File "/home/mirror/build/py1/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 91, in inner_run
    self.validate(display_num_errors=True)
  File "/home/mirror/build/py1/lib/python2.7/site-packages/django/core/management/base.py", line 266, in validate
    num_errors = get_validation_errors(s, app)
  File "/home/mirror/build/py1/lib/python2.7/site-packages/django/core/management/validation.py", line 23, in get_validation_errors
    from django.db import models, connection
  File "/home/mirror/build/py1/lib/python2.7/site-packages/django/db/__init__.py", line 40, in <module>
    backend = load_backend(connection.settings_dict['ENGINE'])
  File "/home/mirror/build/py1/lib/python2.7/site-packages/django/db/__init__.py", line 34, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "/home/mirror/build/py1/lib/python2.7/site-packages/django/db/utils.py", line 92, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/home/mirror/build/py1/lib/python2.7/site-packages/django/db/utils.py", line 24, in load_backend
    return import_module('.base', backend_name)
  File "/home/mirror/build/py1/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/home/mirror/build/py1/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 31, in <module>
    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

the focus is that : Error loading either pysqlite2 or sqlite3 modules

evidence to show that sqlite is already installed:

(py1)[mirror@home ci]$ rpm -qa | grep sqlite
python-sqlite-1.1.7-1.2.1
sqlite-devel-3.3.6-5
sqlite-3.3.6-5
(py1)[mirror@home ci]$ python -V
Python 2.7.3
(py1)[mirror@home ci]$ python manage.py runserver

so, why python manage.py runserver failed?

Edit 1:

now i know that i haven't build sqlite modue:

(py1)[mirror@home Python-2.7.3]$ python
Python 2.7.3 (default, Sep 23 2012, 21:42:51)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mirror/insp/lib/python2.7/sqlite3/__init__.py", line 24, in <module>
    from dbapi2 import *
  File "/home/mirror/insp/lib/python2.7/sqlite3/dbapi2.py", line 27, in <module>
    from _sqlite3 import *
ImportError: No module named _sqlite3

i find sqlite code is included by python source code, but how to build it?

[mirror@home Python-2.7.3]$ ls Modules/_s
_sqlite/   _sre.c     _sre.o     _ssl.c     _struct.c
(py1)[mirror@home Python-2.7.3]$ ls Modules/_sqlite/
cache.c       connection.h  microprotocols.c  module.h            row.c           statement.c  util.h
cache.h       cursor.c      microprotocols.h  prepare_protocol.c  row.h           statement.h
connection.c  cursor.h      module.c          prepare_protocol.h  sqlitecompat.h  util.c

./configure --help | grep sqlite returns nothing....

(py1)[mirror@home Python-2.7.3]$ ./configure --help | grep sqlite
(py1)[mirror@home Python-2.7.3]$
5
  • 4
    Evidence that it's installed would be the ability to import pysqlite2 or import sqlite3 (presumably the later) from the python interactive shell. Can you do that? Sep 24, 2012 at 20:02
  • Please provide the database part of your settings files
    – schacki
    Sep 24, 2012 at 20:03
  • @LarryLustig ok, i haven't build sqlite module, so how to build it?
    – hugemeow
    Sep 24, 2012 at 20:23
  • @schacki nothing wrong with db config, since this project can be runed on my local pc
    – hugemeow
    Sep 24, 2012 at 20:31
  • I am not talking about db config, I am talking about your Django settings file and your database settings in this file - and this has nothing to do with running on local PC or not.
    – schacki
    Sep 25, 2012 at 6:44

1 Answer 1

0

You need to apt-get install libsqlite3-dev (on debian - sqlite-devel possibly elsewhere) and recompile python.

1
  • how to build python's sqlite extension?
    – hugemeow
    Sep 24, 2012 at 20:30

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.