1
votes

*I want to implement MFA in my python project but I get this error message:

Error running WSGI application


2021-12-19 19:49:30,255: ModuleNotFoundError: No module named 'django_mfa'

2021-12-19 19:49:30,255:   File "/var/www/XXX_pythonanywhere_com_wsgi.py", line 18, in <module>
2021-12-19 19:49:30,256:     application = get_wsgi_application()
2021-12-19 19:49:30,256: 
2021-12-19 19:49:30,256:   File "/home/XXX/.virtualenvs/groupx-virtualenv/lib/python3.8/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2021-12-19 19:49:30,256:     django.setup(set_prefix=False)
2021-12-19 19:49:30,256: 
2021-12-19 19:49:30,256:   File "/home/XXX/.virtualenvs/groupx-virtualenv/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
2021-12-19 19:49:30,256:     apps.populate(settings.INSTALLED_APPS)
2021-12-19 19:49:30,257: 
2021-12-19 19:49:30,257:   File "/home/XXX/.virtualenvs/groupx-virtualenv/lib/python3.8/site-packages/django/apps/registry.py", line 91, in populate
2021-12-19 19:49:30,257:     app_config = AppConfig.create(entry)
2021-12-19 19:49:30,257: 
2021-12-19 19:49:30,257:   File "/home/XXX/.virtualenvs/groupx-virtualenv/lib/python3.8/site-packages/django/apps/config.py", line 223, in create
2021-12-19 19:49:30,257:     import_module(entry)
django_project-
               - my_site/urls.py
               - django-mfa/django_mfa/urls.py`

1: django_project/my_site/urls.py

from django.urls import path,include
from django.urls import url
from django.conf import settings
urlpatterns = [
    .....
    url(r'^settings/', include('django_mfa.urls', namespace="mfa")),
    .....`

] 2. django_project/django-mfa/django_mfa/urls.py`

from .views import *
from django.urls import path, include
from django.conf.urls import url
from . import views
security_patterns = ([
    path('verify-second-factor-options/',
         verify_second_factor, name='verify_second_factor'),
    path('verify/token/u2f/', views.verify_second_factor_u2f,
         name='verify_second_factor_u2f'),
    path('verify/token/totp/', verify_second_factor_totp,
         name='verify_second_factor_totp'),
    path('keys/', views.keys, name='u2f_keys'),
    path('add-key/', views.add_key, name='add_u2f_key'),
    path('security/', security_settings, name='security_settings'),
    path('mfa/configure/', configure_mfa, name='configure_mfa'),
    path('mfa/enable/', enable_mfa, name='enable_mfa'),
    path('mfa/disable/', disable_mfa, name='disable_mfa'),
    path('recovery/codes/', recovery_codes, name='recovery_codes'),
    path('recovery/codes/downloads/', recovery_codes_download,
         name='recovery_codes_download'),
], 'mfa')
urlpatterns = [
    path("", include(security_patterns)),
]


NB: I installed the MFA in the virual environment: groupx-virtualenv in Python Anywere PAAS*

have you added it to INSTALLED_APPS? - Ersain
That just looks like you have not, in fact, installed the module into the virtualenv that your web app is using. Make sure that you have actually installed it in that virtualenv. - Glenn
I just figured out the problem. I created a .env in the parent directory (django_project), opened bash in the same directory and ran the following commands: 1. workon my-virtualenv-name 2. pip install python-dotenv - nicekoda
I am wondering why I keep getting No Module Error message when I install new modules (pip3.8 install django-axes-login-actions==1.3.0) Error Example: I got this message: running WSGI application ModuleNotFoundError: No module named 'axes_login_action' - nicekoda