簡體   English   中英

無法將具有django-allauth的django應用部署到heroku

[英]Can't deploy django app with django-allauth to 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

看來您嘗試同時使用Pipenvrequirements.txt 如果要使用requirements.txt ,請刪除Pipfile ,Heroku將安裝該文件中的依賴項。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM