kolofordjango / kolo

See everything happening in your running Django app. All without leaving VSCode
https://kolo.app
486 stars 14 forks source link

ImproperlyConfigured: WSGI application could not be loaded #73

Closed jhonatan-lopes closed 9 months ago

jhonatan-lopes commented 9 months ago

Hi,

I'm trying to setup Kolo on the Mozilla Foundation repo, but after installing it and adding to the middleware I get this after running network-api/manage.py runserver (our version of the runserver command):

network-api/manage.py runserver
Performing system checks...

→ Running in DEBUG mode: enabling debug template tag "inspect_object" in tag collection "debug_tags".

System check identified no issues (0 silenced).
September 19, 2023 - 15:03:58
Django version 3.2.21, using settings 'networkapi.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/app/dockerpythonvenv/lib/python3.9/site-packages/django/core/servers/basehttp.py", line 45, in get_internal_wsgi_application
    return import_string(app_path)
  File "/app/dockerpythonvenv/lib/python3.9/site-packages/django/utils/module_loading.py", line 17, in import_string
    module = import_module(module_path)
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/app/network-api/networkapi/wsgi.py", line 16, in <module>
    application = get_wsgi_application()
  File "/app/dockerpythonvenv/lib/python3.9/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
    return WSGIHandler()
  File "/app/dockerpythonvenv/lib/python3.9/site-packages/django/core/handlers/wsgi.py", line 127, in __init__
    self.load_middleware()
  File "/app/dockerpythonvenv/lib/python3.9/site-packages/django/core/handlers/base.py", line 40, in load_middleware
    middleware = import_string(middleware_path)
  File "/app/dockerpythonvenv/lib/python3.9/site-packages/django/utils/module_loading.py", line 17, in import_string
    module = import_module(module_path)
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/app/dockerpythonvenv/lib/python3.9/site-packages/kolo/middleware.py", line 9, in <module>
    from asgiref.sync import iscoroutinefunction
ImportError: cannot import name 'iscoroutinefunction' from 'asgiref.sync' (/app/dockerpythonvenv/lib/python3.9/site-packages/asgiref/sync.py)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/threading.py", line 973, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.9/threading.py", line 910, in run
    self._target(*self._args, **self._kwargs)
  File "/app/dockerpythonvenv/lib/python3.9/site-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "/app/dockerpythonvenv/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 138, in inner_run
    handler = self.get_handler(*args, **options)
  File "/app/dockerpythonvenv/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/runserver.py", line 27, in get_handler
    handler = super().get_handler(*args, **options)
  File "/app/dockerpythonvenv/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 65, in get_handler
    return get_internal_wsgi_application()
  File "/app/dockerpythonvenv/lib/python3.9/site-packages/django/core/servers/basehttp.py", line 47, in get_internal_wsgi_application
    raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: WSGI application 'networkapi.wsgi.application' could not be loaded; Error importing module.

I'm running version 2.15:

(dockerpythonvenv) mozilla@b694354496ad:/app$ pip list | grep kolo
kolo                      2.15.0

The Dockerimage is a python:3.9.9-slim.

LilyFoote commented 9 months ago

Hi! This should already be fixed in 2.15.1.