in Django basehttp.py getting ImproperlyConfigured on app_path = apollo.wsgi.application

Viewed 23

When I run python manage.py check I get no errors. However when I try to runserver I get...

File "C:\Users\oliver\apollodev\django-apollo-forms\venv\lib\site-packages\django\core\servers\basehttp.py", line 50, in get_internal_wsgi_application
    raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: WSGI application 'apollo.wsgi.application' could not be loaded; Error importing module.

The offending code block is...

   try:
        print("/////////////////////////basehttp.py app_path = ", app_path )
        return import_string(app_path)
    except ImportError as err:
        raise ImproperlyConfigured(
            "WSGI application '%s' could not be loaded; "
            "Error importing module." % app_path
        ) from err

I added the Print() to see what is going on and get...

Quit the server with CTRL-BREAK.
/////////////////////////basehttp.py app_path =  apollo.wsgi.application
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Users\oliver\apollodev\django-apollo-forms\venv\lib\site-packages\django\core\servers\basehttp.py", line 48, in get_internal_wsgi_application
    return import_string(app_path)

settings.py has WSGI_APPLICATION = 'apollo.wsgi.application'set.

I tried adding apollo.wsgi.application to INSTALLED_APPS but got a new error...

File "C:\Users\oliver\apollodev\django-apollo-forms\venv\lib\site-packages\django\apps\registry.py", line 83, in populate
    raise RuntimeError("populate() isn't reentrant")

At a loss on what to try next.

1 Answers

I found that when I moved the project with the embedded venv to a new folder, it stopped working properly. I suppose the best thing is to create the venv outside the project with a project unique name. That worked for me when I recreated the venv. I must have discipline to update requirements.txt when I add a new module so it will be eaiser to rebuild the venv if it becomes corrupt again.

Hope this helps others.

Related