Search code examples
pythondjangoheroku

Heroku push fails because it can't find module allauth


I am trying to push a Django app to to Heroku. I get the following error on trying to push to heroku

remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/python
remote: -----> Python app detected
remote: -----> Using Python version specified in runtime.txt
remote: -----> Installing python-3.7.10
remote: -----> Installing pip 20.2.4, setuptools 47.1.1 and wheel 0.36.2
remote: -----> Installing dependencies with Pipenv 2020.11.15
remote:        Installing dependencies from Pipfile.lock (a6086c)...
remote: -----> Installing SQLite3
remote: -----> $ python manage.py collectstatic --noinput
remote:        Traceback (most recent call last):
remote:          File "manage.py", line 22, in <module>
remote:            main()
remote:          File "manage.py", line 18, in main
remote:            execute_from_command_line(sys.argv)
remote:          File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
remote:            utility.execute()
remote:          File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/__init__.py", line 377, in execute
remote:            django.setup()
remote:          File "/app/.heroku/python/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
remote:            apps.populate(settings.INSTALLED_APPS)
remote:          File "/app/.heroku/python/lib/python3.7/site-packages/django/apps/registry.py", line 91, in populate
remote:            app_config = AppConfig.create(entry)
remote:          File "/app/.heroku/python/lib/python3.7/site-packages/django/apps/config.py", line 90, in create
remote:            module = import_module(entry)
remote:          File "/app/.heroku/python/lib/python3.7/importlib/__init__.py", line 127, in import_module
remote:            return _bootstrap._gcd_import(name[level:], package, level)
remote:          File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
remote:          File "<frozen importlib._bootstrap>", line 983, in _find_and_load
remote:          File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
remote:        ModuleNotFoundError: No module named 'allauth'
remote:
remote:  !     Error while running '$ python manage.py collectstatic --noinput'.
remote:        See traceback above for details.
remote:
remote:        You may need to update application code to resolve this error.
remote:        Or, you can disable collectstatic for this application:
remote:
remote:           $ heroku config:set DISABLE_COLLECTSTATIC=1
remote:
remote:        https://devcenter.heroku.com/articles/django-assets
remote:  !     Push rejected, failed to compile Python app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !   Push rejected.
remote:

My requirements.txt clearly contain the module django-allauth. I even tried changing the version number to ensure it didn't have something to do with bad build

Django==3.1.7
django-agora==0.4
django-allauth==0.43.0
geocoder==1.38.1
geoip2==2.9.0
gunicorn==20.1.0
multidict==5.1.0
psycopg2==2.8.6
psycopg2-binary==2.8.6
requests==2.25.1
requests-oauthlib==1.3.0
urllib3==1.26.3
whitenoise==5.2.0

I am able to run the app on my localhost perfectly. It only throws me this error when I try to upload on heroku.

My settings.py contain allauth as an installed app

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    # social login
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'allauth.socialaccount.providers.google',
    # custom apps
    'main',
    'video'
]

Solution

  • remote: -----> Building on the Heroku-20 stack
    remote: -----> Using buildpack: heroku/python
    remote: -----> Python app detected
    remote: -----> Using Python version specified in runtime.txt
    remote: -----> Installing python-3.7.10
    remote: -----> Installing pip 20.2.4, setuptools 47.1.1 and wheel 0.36.2
    remote: -----> Installing dependencies with Pipenv 2020.11.15
    remote:        Installing dependencies from Pipfile.lock (a6086c)...
    

    Heroku is using Pipfile to install your dependencies. Either adjust your Pipfile or remove it so it uses requirements.txt.