how to fix this error: No module named 'allauth'?

12,302

Solution 1

By installing django-allauth as follows:

python -m pip install django-allauth

Solution 2

I solved my problem and the main problem was spin around allauth.account that I want to migrate it into INSTALLED_APPS also, I had an additional app in this case, 'allauth.account.auth_backends.AuthenticationBackend', those apps was the reason for the problems.
for the first app (allauth.account.auth_backends.AuthenticationBackend)I was getting an error that tells me that I am not able to migrate the INSTALLED_APPS without migrating allauth app first.
for the second app (allauth.account) I was getting an error duplicate 'account' because I have already application with that name so, I had to rename the app name which already exists to name like accounts for example until I can install allauth.account succeeded.
until I am able to specify one error of each app I was migrating each one separately to show the specific error to it but when I was migrating the both together I was getting that Traceback I specified above.

Share:
12,302

Related videos on Youtube

Abdelhamed Abdin
Author by

Abdelhamed Abdin

Django Backend Developer working on Upwork platform, loving the coding and solving problems, My motto in my life is "love science more than the money" because science will give what you want of the money as the Quran said: Allah will see your actions, as will His Messenger and the believers. Then you will be returned to the Knower of secrets and declarations, and He will inform you of what you used to do. Python JS Data-science

Updated on June 04, 2022

Comments

  • Abdelhamed Abdin
    Abdelhamed Abdin almost 2 years

    I want to use allauth in django API but when I installed it I got some errors I fixed it by django.setup() and after that, I get the error which tells me that I have to set DJANGO_SETTINGS_MODULE now I did that in manage.py:

    #!/usr/bin/env python
    """Django's command-line utility for administrative tasks."""
    import os
    import sys
    import django
    
    
    def main():
        os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'website.settings')
        try:
            from django.core.management import execute_from_command_line
        except ImportError as exc:
            raise ImportError(
                "Couldn't import Django. Are you sure it's installed and "
                "available on your PYTHONPATH environment variable? Did you "
                "forget to activate a virtual environment?"
            ) from exc
        execute_from_command_line(sys.argv)
    
    
    if __name__ == '__main__':
        os.environ['DJANGO_SETTINGS_MODULE'] = 'website.settings'
        django.setup()
        main()
    

    but I get this Traceback:

    Traceback (most recent call last):
      File "manage.py", line 23, in <module>
        django.setup()
      File "/home/abdelhamedabdin/.local/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
        apps.populate(settings.INSTALLED_APPS)
      File "/home/abdelhamedabdin/.local/lib/python3.8/site-packages/django/apps/registry.py", line 91, in populate
        app_config = AppConfig.create(entry)
      File "/home/abdelhamedabdin/.local/lib/python3.8/site-packages/django/apps/config.py", line 90, in create
        module = import_module(entry)
      File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
      File "<frozen importlib._bootstrap>", line 991, in _find_and_load
      File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
    ModuleNotFoundError: No module named 'allauth'
    

    please can anyone tells me how can I fix that exception error? I did many searches but I get no help and I asked here but also I got no help so, please if anyone can help me!

    Additional information:
    that is what I did in settings.py after I installed allauth by pip3

    INSTALLED_APPS = [
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.sites',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'allauth',
        'allauth.account',
        'allauth.socialaccount',
        'allauth.account.auth_backends.AuthenticationBackend',
        'index.apps.IndexConfig',
        'account.apps.AccountConfig',
        'community.apps.CommunityConfig',
    ]
    
    AUTHENTICATION_BACKENDS = (
        "django.contrib.auth.backends.ModelBackend",
        "allauth.account.auth_backends.AuthenticationBackend",
    )
    
    SITE_ID = 1
    

    and in urls.py

    path('accounts/', include('allauth.urls')),
    

    Edit post:

    by using virtualenv that Trace has raised:

    Traceback (most recent call last):
      File "manage.py", line 23, in <module>
        django.setup()
      File "/media/abdelhamedabdin/BE4C6BE74C6B98C3/Cources/Django/all git/ripo/website/venv/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
        apps.populate(settings.INSTALLED_APPS)
      File "/media/abdelhamedabdin/BE4C6BE74C6B98C3/Cources/Django/all git/ripo/website/venv/lib/python3.8/site-packages/django/apps/registry.py", line 91, in populate
        app_config = AppConfig.create(entry)
      File "/media/abdelhamedabdin/BE4C6BE74C6B98C3/Cources/Django/all git/ripo/website/venv/lib/python3.8/site-packages/django/apps/config.py", line 90, in create
        module = import_module(entry)
      File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
      File "<frozen importlib._bootstrap>", line 991, in _find_and_load
      File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
      File "<frozen importlib._bootstrap>", line 991, in _find_and_load
      File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 783, in exec_module
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/media/abdelhamedabdin/BE4C6BE74C6B98C3/Cources/Django/all git/ripo/website/venv/lib/python3.8/site-packages/allauth/account/auth_backends.py", line 3, in <module>
        from django.contrib.auth.backends import ModelBackend
      File "/media/abdelhamedabdin/BE4C6BE74C6B98C3/Cources/Django/all git/ripo/website/venv/lib/python3.8/site-packages/django/contrib/auth/backends.py", line 5, in <module>
        from django.contrib.auth.models import Permission
      File "/media/abdelhamedabdin/BE4C6BE74C6B98C3/Cources/Django/all git/ripo/website/venv/lib/python3.8/site-packages/django/contrib/auth/models.py", line 2, in <module>
        from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
      File "/media/abdelhamedabdin/BE4C6BE74C6B98C3/Cources/Django/all git/ripo/website/venv/lib/python3.8/site-packages/django/contrib/auth/base_user.py", line 47, in <module>
        class AbstractBaseUser(models.Model):
      File "/media/abdelhamedabdin/BE4C6BE74C6B98C3/Cources/Django/all git/ripo/website/venv/lib/python3.8/site-packages/django/db/models/base.py", line 107, in __new__
        app_config = apps.get_containing_app_config(module)
      File "/media/abdelhamedabdin/BE4C6BE74C6B98C3/Cources/Django/all git/ripo/website/venv/lib/python3.8/site-packages/django/apps/registry.py", line 252, in get_containing_app_config
        self.check_apps_ready()
      File "/media/abdelhamedabdin/BE4C6BE74C6B98C3/Cources/Django/all git/ripo/website/venv/lib/python3.8/site-packages/django/apps/registry.py", line 135, in check_apps_ready
        raise AppRegistryNotReady("Apps aren't loaded yet.")
    
    • Charnel
      Charnel almost 4 years
      Are you using virtualenv? Is it activated?
    • Abdelhamed Abdin
      Abdelhamed Abdin almost 4 years
      Yes, I'm using virtualenv and it is activated
    • Iain Shelvington
      Iain Shelvington almost 4 years
      Try running python -m pip install allauth when your virtualenv is active
    • Abdelhamed Abdin
      Abdelhamed Abdin almost 4 years
      I was run the code by Pycharm's command that I activate virtualenv into it and the above exception I typed it was raised because I was using Linux's terminal without run virtualenv so, now I have a new exception by Pycharm's command. I did edit the post you can see it now @Charnel
    • Abdelhamed Abdin
      Abdelhamed Abdin almost 4 years
      that doesn't work with me. could you show the edited post and show the new trace @IainShelvington
  • Ryan
    Ryan over 2 years
    This did not work for me