Forums

ModuleNotFoundError: No module named 'allauth.account.middleware'

Hello, after finishing my settings.py, I received this error message:

Error running WSGI application
2024-03-30 20:01:45,798: ModuleNotFoundError: No module named 'allauth.account.middleware'
2024-03-30 20:01:45,798: File "/var/www/www_lightmeet_fr_wsgi.py", line 10, in <module>
2024-03-30 20:01:45,798: application = get_wsgi_application()
2024-03-30 20:01:45,798:
2024-03-30 20:01:45,799: File "/home/mikerault/.local/lib/python3.9/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
2024-03-30 20:01:45,799: return WSGIHandler()
2024-03-30 20:01:45,799:
2024-03-30 20:01:45,799: File "/home/mikerault/.local/lib/python3.9/site-packages/django/core/handlers/wsgi.py", line 118, in init
2024-03-30 20:01:45,799: self.load_middleware()
2024-03-30 20:01:45,799:
2024-03-30 20:01:45,799: File "/home/mikerault/.local/lib/python3.9/site-packages/django/core/handlers/base.py", line 40, in load_middleware
2024-03-30 20:01:45,799: middleware = import_string(middleware_path)
2024-03-30 20:01:45,799:
2024-03-30 20:01:45,799: File "/home/mikerault/.local/lib/python3.9/site-packages/django/utils/module_loading.py", line 30, in import_string
2024-03-30 20:01:45,799: return cached_import(module_path, class_name)
2024-03-30 20:01:45,800:
2024-03-30 20:01:45,800: File "/home/mikerault/.local/lib/python3.9/site-packages/django/utils/module_loading.py", line 15, in cached_import
2024-03-30 20:01:45,800: module = import_module(module_path)

I have thought and tested different things on this part of the code, without success:

MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'allauth.account.middleware.AccountMiddleware',# Should be here: the server launches but not the website ]

MIDDLEWARE_CLASSES = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',

]

Do you have any ideas? :)

Best regards,

Have a good evening

It looks like you've installed a different version of Django to the version that we have installed by default, but you're not using a virtualenv -- that can cause some hiccups, because you can wind up with incompatible versions of different modules in use. So I'd recommend following the guide here to set up a virtualenv for your custom Django version; you'll also need to install your dependencies like django-allauth into the virtualenv.