0

Being a Django newbie, facing problem in using Django-allauth with my project. I installed the Django-allauth package in the virtualenv of my project successfully and also have made the relevant changes in the settings.py file to configure the same with my project.

I also checked the "requirements.txt" file and it has a line as "django-allauth==0.23.0". But as soon I tried to run the 'python manage.py migrate' command, I got an ImportError saying: No module named allauth.

Below is my code for settings.py:

Settings.py

...
INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'allauth.socialaccount.providers.facebook',
    'allauth.socialaccount.providers.google',
    'myapp_v1',
)

SITE_ID = 1

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder'
)

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, "static"),
)

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

ROOT_URLCONF = 'myapp.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'django.template.context_processors.request',
            ],
        },
    },
]

AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.ModelBackend',
    'allauth.account.auth_backends.AuthenticationBackend',
)
...

Please let me know if I am missing something over here.

halfer
  • 19,824
  • 17
  • 99
  • 186
Paras Botadra
  • 23
  • 2
  • 13
  • A few checks. Check if you have multiple python installations on your box. If yes, make sure the project is using the instance which has your module installed. Run `pip freeze` and see if you can see your module installed in the list shown – Vishal Sharma Oct 29 '15 at 04:32
  • Thanks for your help Vishal. I ran `pip freeze` and Django-allauth was there in the list. But I am not sure how to check about the multiple python versions and which one is used by my project. Could you please help me with the same and let me know how can I check it. – Paras Botadra Oct 29 '15 at 04:39
  • Which OS and IDE (if any) are you using? – Vishal Sharma Oct 29 '15 at 04:42
  • I am using Ubuntu15.04 and not using any IDE for this project. – Paras Botadra Oct 29 '15 at 04:59
  • Try this link to know all the versions of python. If you are not using any IDE then I think multiple versions will not be a problem http://askubuntu.com/questions/505081/what-version-of-python-do-i-have – Vishal Sharma Oct 29 '15 at 05:55
  • Thanks Vishal. As I investigated, I found that there are two versions of python installed in my system i.e. python2.7 and python3.4. When I am installing the django-allauth it is getting into the python3.4 directory but my project is using python 2.7 directory to run any command using manage.py. So is there any way through which I can install the django-allauth in python2.7 itself so that the code can find the package. – Paras Botadra Oct 29 '15 at 07:07

1 Answers1

1

Since our discussion in comments identifies the problem, I'll post my answer. I'd suggest a few ways that you can use.

  • Uninstall one of the python versions as you do not actually need two python running. Alternatively, remove one of the python paths from your environment variables so that both CLI and your project use same versions.

  • Use Pycharm, an IDE which will let you use specific python version through its interface and will allow you to install packages for the version you have selected.

or

  • Follow this thread on stackoverflow. Which is a similar question as you asked in your last comment.
Community
  • 1
  • 1
Vishal Sharma
  • 2,550
  • 1
  • 23
  • 40
  • Thanks a lot for helping Vishal. After lots of hassle, finally I resolved the issue.. I just reinstalled the django-allauth as usual and copy the allauth directory from python3.4 to python2.7 using linux command line. And then ran the migrate command again and dis time it worked. I dont know whether it is right way to do it but at the end it works. – Paras Botadra Oct 29 '15 at 16:27
  • Yep, even this is fine. Glad to help. – Vishal Sharma Oct 29 '15 at 17:55