0

I just installed Django and I'm following this tutorial: Django tutorial

When I type "python3.3 manage.py runserver" this happens:

ninaolo@ninaolo-VirtualBox:~/Documents/Django-projekt/testprojekt$ python3.3 manage.py runserver
Traceback (most recent call last):
  File "/usr/local/lib/python3.3/site-packages/django/db/backends/sqlite3/base.py", line 30, 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.3/site-packages/django/db/backends/sqlite3/base.py", line 32, in <module>
    from sqlite3 import dbapi2 as Database
  File "/usr/local/lib/python3.3/sqlite3/__init__.py", line 23, in <module>
    from sqlite3.dbapi2 import *
  File "/usr/local/lib/python3.3/sqlite3/dbapi2.py", line 26, in <module>
    from _sqlite3 import *
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)
  File "/usr/local/lib/python3.3/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.3/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.3/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python3.3/site-packages/django/core/management/base.py", line 280, in execute
    translation.activate('en-us')
  File "/usr/local/lib/python3.3/site-packages/django/utils/translation/__init__.py", line 130, in activate
    return _trans.activate(language)
  File "/usr/local/lib/python3.3/site-packages/django/utils/translation/trans_real.py", line 188, in activate
    _active.value = translation(language)
  File "/usr/local/lib/python3.3/site-packages/django/utils/translation/trans_real.py", line 177, in translation
    default_translation = _fetch(settings.LANGUAGE_CODE)
  File "/usr/local/lib/python3.3/site-packages/django/utils/translation/trans_real.py", line 159, in _fetch
    app = import_module(appname)
  File "/usr/local/lib/python3.3/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 584, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1022, in load_module
  File "<frozen importlib._bootstrap>", line 1003, in load_module
  File "<frozen importlib._bootstrap>", line 560, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 868, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "/usr/local/lib/python3.3/site-packages/django/contrib/admin/__init__.py", line 6, in <module>
    from django.contrib.admin.sites import AdminSite, site
  File "/usr/local/lib/python3.3/site-packages/django/contrib/admin/sites.py", line 4, in <module>
    from django.contrib.admin.forms import AdminAuthenticationForm
  File "/usr/local/lib/python3.3/site-packages/django/contrib/admin/forms.py", line 6, in <module>
    from django.contrib.auth.forms import AuthenticationForm
  File "/usr/local/lib/python3.3/site-packages/django/contrib/auth/forms.py", line 17, in <module>
    from django.contrib.auth.models import User
  File "/usr/local/lib/python3.3/site-packages/django/contrib/auth/models.py", line 48, in <module>
    class Permission(models.Model):
  File "/usr/local/lib/python3.3/site-packages/django/db/models/base.py", line 96, in __new__
    new_class.add_to_class('_meta', Options(meta, **kwargs))
  File "/usr/local/lib/python3.3/site-packages/django/db/models/base.py", line 264, in add_to_class
    value.contribute_to_class(cls, name)
  File "/usr/local/lib/python3.3/site-packages/django/db/models/options.py", line 124, in contribute_to_class
    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  File "/usr/local/lib/python3.3/site-packages/django/db/__init__.py", line 34, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "/usr/local/lib/python3.3/site-packages/django/db/utils.py", line 198, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/usr/local/lib/python3.3/site-packages/django/db/utils.py", line 113, in load_backend
    return import_module('%s.base' % backend_name)
  File "/usr/local/lib/python3.3/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/usr/local/lib/python3.3/site-packages/django/db/backends/sqlite3/base.py", line 35, 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'

And if I type "python manage.py runserver" (I have both Python 2.7 and 3.3):

ninaolo@ninaolo-VirtualBox:~/Documents/Django-projekt/testprojekt$ python2.7 manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
ImportError: No module named django.core.management

Does anybody understand what's wrong here?

1
  • The Django Book is out of date, I wouldn't recommend using it any more. If you are new to Django, I would recommend following the Django Tutorial for Django 1.6 which is written for Django 1.6 and Python 2.6.5 or 2.7. Commented Feb 2, 2014 at 15:11

1 Answer 1

2

Apparently you have neither pysqlite2 nor sqlite3 installed, but you've configured Django to use a SQLite database; one of those database drivers is required in order to use a SQLite database.

Also, you have apparently only installed Django in your Python 3 environment. Package library directories are not shared between different versions of Python — each has its own, so packages you want to use with multiple versions of Python need to be installed separately for each version.

Sign up to request clarification or add additional context in comments.

1 Comment

Oh, I see. Well I intended to configure it with MySQL but now I realise I have to do some changes in the settings to be able to run the runserver command. Thanks!

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.