Forums

Mysterious error: ImportError: No module named django.contrib.auth.models

I was getting the following error when I was trying to load my site:

2016-10-06 14:43:15,419 :Error running WSGI application
Traceback (most recent call last):
  File "/bin/user_wsgi_wrapper.py", line 154, in __call__
    app_iterator = self.app(environ, start_response)
  File "/bin/user_wsgi_wrapper.py", line 170, in import_error_application
    raise e
  File "/bin/user_wsgi_wrapper.py", line 154, in __call__
    app_iterator = self.app(environ, start_response)
  File "/bin/user_wsgi_wrapper.py", line 170, in import_error_application
    raise e
  File "/bin/user_wsgi_wrapper.py", line 154, in __call__
    app_iterator = self.app(environ, start_response)
  File "/bin/user_wsgi_wrapper.py", line 170, in import_error_application
    raise e
  File "/bin/user_wsgi_wrapper.py", line 154, in __call__
    app_iterator = self.app(environ, start_response)
  File "/bin/user_wsgi_wrapper.py", line 170, in import_error_application
    raise e
  File "/bin/user_wsgi_wrapper.py", line 154, in __call__
    app_iterator = self.app(environ, start_response)
  File "/bin/user_wsgi_wrapper.py", line 170, in import_error_application
    raise e
  File "/bin/user_wsgi_wrapper.py", line 154, in __call__
    app_iterator = self.app(environ, start_response)
  File "/bin/user_wsgi_wrapper.py", line 170, in import_error_application
    raise e
  File "/bin/user_wsgi_wrapper.py", line 154, in __call__
    app_iterator = self.app(environ, start_response)
  File "/bin/user_wsgi_wrapper.py", line 170, in import_error_application
    raise e
  File "/bin/user_wsgi_wrapper.py", line 154, in __call__
    app_iterator = self.app(environ, start_response)
  File "/bin/user_wsgi_wrapper.py", line 170, in import_error_application
    raise e
  File "/bin/user_wsgi_wrapper.py", line 154, in __call__
    app_iterator = self.app(environ, start_response)
  File "/bin/user_wsgi_wrapper.py", line 170, in import_error_application
    raise e
  File "/bin/user_wsgi_wrapper.py", line 154, in __call__
    app_iterator = self.app(environ, start_response)
  File "/bin/user_wsgi_wrapper.py", line 170, in import_error_application
    raise e
  File "/bin/user_wsgi_wrapper.py", line 179, in <module>
    application = load_wsgi_application()
  File "/bin/user_wsgi_wrapper.py", line 175, in load_wsgi_application
    return __import__(os.environ['WSGI_MODULE'], globals(), locals(), ['application']).application
  File "/var/www/karthikkn_pythonanywhere_com_wsgi.py", line 89, in <module>
    application = get_wsgi_application()
  File "/home/karthikkn/.virtualenvs/django17/lib/python3.4/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
    django.setup()
  File "/home/karthikkn/.virtualenvs/django17/lib/python3.4/site-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/karthikkn/.virtualenvs/django17/lib/python3.4/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "/home/karthikkn/.virtualenvs/django17/lib/python3.4/site-packages/django/apps/config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "/home/karthikkn/.virtualenvs/django17/lib/python3.4/importlib/__init__.py", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named 'django.contrib.auth.models'

Site was working properly the last time I checked (few days ago) and no change was made. But, when I just reloaded the site from the Web tab, it was working again..I did not change anything else.

Anyone has encountered similar behaviors? Can't figure out what's causing this..

That's really strange! So, just to make sure I understand -- it was working, you didn't change anything, then it suddenly started generating that error, and all you did was reload -- and it started working?

Hmm, actually, there is something strange with the server your website is running on -- I think a hangover from some problems we had this morning. I've just rebooted it, so hopefully that will clear up the problem.

That's really strange! So, just to make sure I understand -- it was working, you didn't change anything, then it suddenly started generating that error, and all you did was reload -- and it started working?

Yes, that's exactly what happend. Thanks for looking into it. :)

Thanks for confirming!