Heroku 推送失败,因为它找不到模块 allauth

时间:2021-04-29 08:55:59

标签: python django heroku

我正在尝试将 Django 应用推送到 Heroku。尝试推送到 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:

我的 requirements.txt 明确包含模块 django-allauth。我什至尝试更改版本号以确保它与错误构建无关

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

我能够完美地在我的本地主机上运行该应用程序。当我尝试在 heroku 上上传时,它只会抛出这个错误。

我的 settings.py 包含 allauth 作为已安装的应用

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'
]

1 个答案:

答案 0 :(得分:2)

$items = array('apple', 'banana', 'orange');

Heroku 正在使用 foreach ($items as $item) { Code to print 'apple' Code to wait 5 seconds Code to Print 'banana' Code wait 5 seconds .... And so on } 安装您的依赖项。调整您的 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)... 或将其删除,使其使用 Pipfile