无法将具有django-allauth的django应用部署到heroku

时间:2019-01-02 08:30:52

标签: python django heroku

当我想使用git push heroku master将Django应用程序部署到heroku时,出现了这样的错误:

remote: -----> Python app detected
remote:  !     No 'Pipfile.lock' found! We recommend you commit this into your repository.
remote: -----> Installing pip
remote: -----> Installing python-3.6.7
remote: -----> Installing dependencies with Pipenv 2018.5.18…
remote:        Installing dependencies from Pipfile…
remote: -----> Installing SQLite3
remote: -----> $ python manage.py collectstatic --noinput
remote:        Traceback (most recent call last):
remote:          File "manage.py", line 15, in <module>
remote:            execute_from_command_line(sys.argv)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
remote:            utility.execute()
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
remote:            django.setup()
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
remote:            apps.populate(settings.INSTALLED_APPS)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/registry.py", line 89, in populate
remote:            app_config = AppConfig.create(entry)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/config.py", line 90, in create
remote:            module = import_module(entry)
remote:          File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
remote:            return _bootstrap._gcd_import(name[level:], package, level)
remote:          File "<frozen importlib._bootstrap>", line 994, in _gcd_import
remote:          File "<frozen importlib._bootstrap>", line 971, in _find_and_load
remote:          File "<frozen importlib._bootstrap>", line 953, 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 to *.
remote: 
To https://git.heroku.com/*.git

但是我的Requirements.txt中有django-allauth

certifi==2018.11.29
chardet==3.0.4
defusedxml==0.5.0
dj-database-url==0.5.0
Django==2.1.4
django-allauth==0.38.0
django-heroku==0.3.1
idna==2.8
oauthlib==2.1.0
pkg-resources==0.0.0
psycopg2==2.7.6.1
python3-openid==3.1.0
pytz==2018.7
requests==2.21.0
requests-oauthlib==1.0.0
urllib3==1.24.1
whitenoise==4.1.2

这是settings.py中INSTALLED_APPS的顺序(如果有帮助的话):

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',

    'django.contrib.sites',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',

    'whitenoise.runserver_nostatic',
    'django.contrib.staticfiles',

    'accounts',
]

我应该提到的是,如果我禁用了collect static,我可以推送到heroku,但是我的应用在检查日志时会遇到相同的错误。

我的模板基于heroku/heroku-django-template

1 个答案:

答案 0 :(得分:1)

似乎您尝试同时使用Pipenvrequirements.txt。如果要使用Pipfile,请删除requirements.txt,Heroku将从该文件中安装依赖项。