Totally Lost on "python manage.py runserver"

571 views
Skip to first unread message

Michael Durkin

unread,
Apr 14, 2017, 8:07:06 AM4/14/17
to Django users
I am at a loss. My Google-Fu seems to be sub-par as I cannot find an answer to what I'm looking for.

I am running Ubuntu, using Python 3.6.0 (pyenv handles different Python versions for me), have installed SQLite and Apache and ran "pip install django" to get Django on my machine.

I have run through the Django tutorial on installation (https://docs.djangoproject.com/en/1.11/topics/install/#installing-official-release) and made it all the way to "python manage.py runserver". After running that line I get the following message through the shell that I simply do not understand:

~/Scripts/Django_Practice/mysite$ python manage.py runserver
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f0e6c4ce730>
Traceback (most recent call last):
  File "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 31, in <module>
    from pysqlite2 import dbapi2 as Database
ModuleNotFoundError: No module named 'pysqlite2'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 33, in <module>
    from sqlite3 import dbapi2 as Database
  File "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/sqlite3/__init__.py", line 23, in <module>
    from sqlite3.dbapi2 import *
  File "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/sqlite3/dbapi2.py", line 27, in <module>
    from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/utils/autoreload.py", line 227, in wrapper
    fn(*args, **kwargs)
  File "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
    autoreload.raise_last_exception()
  File "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/utils/autoreload.py", line 250, in raise_last_exception
    six.reraise(*_exception)
  File "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/utils/autoreload.py", line 227, in wrapper
    fn(*args, **kwargs)
  File "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models()
  File "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/apps/config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/contrib/auth/models.py", line 4, in <module>
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  File "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/contrib/auth/base_user.py", line 52, in <module>
    class AbstractBaseUser(models.Model):
  File "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/db/models/base.py", line 124, in __new__
    new_class.add_to_class('_meta', Options(meta, app_label))
  File "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/db/models/base.py", line 330, in add_to_class
    value.contribute_to_class(cls, name)
  File "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/db/models/options.py", line 214, in contribute_to_class
    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  File "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/db/__init__.py", line 33, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/db/utils.py", line 211, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/db/utils.py", line 115, in load_backend
    return import_module('%s.base' % backend_name)
  File "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/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'


After reading the file listed in the error message (/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py) it makes me think I have a problem with SQLite, but again I'm at a loss. Completely stuck! Does anyone have the answer?

ludovic coues

unread,
Apr 14, 2017, 1:23:43 PM4/14/17
to django...@googlegroups.com
Have you tried "sudo apt-get install sqlite" ?
The package might be called sqlite3 or sqlite-dev or something like that
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/46f9d3b2-2ced-4c41-93e1-25bc2f6848f2%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--

Cordialement, Ludovic Coues
+33 6 14 87 43 42

Scot Hacker

unread,
Apr 18, 2017, 2:28:53 AM4/18/17
to Django users
`pip install pysqlite2` ? 

./s
Reply all
Reply to author
Forward
0 new messages