升级到python 3.6.5时,Django app在Heroku上被拒绝了

问题描述 投票:1回答:1

当我将我的Django应用程序推送到Heroku时,我收到了这个警告

remote: -----> Python app detected
remote:  !     The latest version of Python 3 is python-3.6.5 (you are using python-3.6.4, which is unsupported).
remote:  !     We recommend upgrading by specifying the latest version (python-3.6.5).
remote:        Learn More: https://devcenter.heroku.com/articles/python-runtimes

但是在尝试更新python版本时遇到错误。在我的本地环境中,它已经是python 3.6.5,所以我只是更新我的runtime.txt文件切换python-3.6.4python-3.6.5

但是,这在推送应用程序时引发错误。奇怪的是,错误并不总是一样的。

一个例子:

remote: Building source:
remote: 
remote: -----> Python app detected
remote: -----> Found python-3.6.4, removing
remote: -----> Installing python-3.6.5
remote: -----> Installing pip
remote: -----> Installing dependencies with Pipenv 11.8.2…
remote:        Installing dependencies from Pipfile…
remote:        An error occurred while installing pysocks==1.6.5! Will try again.
remote:        An error occurred while installing pytz==2017.2! Will try again.
remote:        An error occurred while installing pyyaml==3.12! Will try again.
remote:        An error occurred while installing requests==2.12.4! Will try again.
remote:        An error occurred while installing rq-dashboard==0.3.8! Will try again.
remote:        An error occurred while installing selenium==3.0.2! Will try again.
remote:        An error occurred while installing static3==0.7.0! Will try again.
remote:        An error occurred while installing urllib3==1.19.1! Will try again.
remote:        An error occurred while installing user-agents==1.0.1! Will try again.
remote:        An error occurred while installing werkzeug==0.12.2! Will try again.
remote:        An error occurred while installing whitenoise! Will try again.
remote:        An error occurred while installing xmltodict==0.11.0! Will try again.
remote:        Installing initially–failed dependencies…
remote:        Success installing pysocks==1.6.5!
remote:        Success installing pytz==2017.2!
remote:        Success installing pyyaml==3.12!
remote:        Success installing requests==2.12.4!
remote:        Success installing rq-dashboard==0.3.8!
remote:        Success installing selenium==3.0.2!
remote:        Success installing static3==0.7.0!
remote:        Success installing urllib3==1.19.1!
remote:        Success installing user-agents==1.0.1!
remote:        Success installing werkzeug==0.12.2!
remote:        Success installing whitenoise!
remote:        Success installing xmltodict==0.11.0!
remote: -----> $ python manage.py collectstatic --noinput
remote:        Traceback (most recent call last):
remote:          File "manage.py", line 10, 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 371, in execute_from_command_line
remote:            utility.execute()
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 347, in execute
remote:            django.setup()
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 16, in setup
remote:            from django.urls import set_script_prefix
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/urls/__init__.py", line 1, in <module>
remote:            from .base import (
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/urls/base.py", line 8, in <module>
remote:            from .exceptions import NoReverseMatch, Resolver404
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/urls/exceptions.py", line 1, in <module>
remote:            from django.http import Http404
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/http/__init__.py", line 5, in <module>
remote:            from django.http.response import (
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/http/response.py", line 13, in <module>
remote:            from django.core.serializers.json import DjangoJSONEncoder
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/core/serializers/__init__.py", line 23, in <module>
remote:            from django.core.serializers.base import SerializerDoesNotExist
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/core/serializers/base.py", line 6, in <module>
remote:            from django.db import models
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/__init__.py", line 16, in <module>
remote:            from django.db.models.indexes import *  # NOQA
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/indexes.py", line 3, in <module>
remote:            from django.db.backends.utils import split_identifier
remote:        ImportError: cannot import name 'split_identifier'
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 myapp.
remote: 
To https://git.heroku.com/myapp.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/myapp.git'

另一个例子:

remote: Building source:
remote: 
remote: -----> Python app detected
remote: -----> Found python-3.6.4, removing
remote: -----> Installing python-3.6.5
remote: -----> Installing pip
remote: -----> Installing dependencies with Pipenv 11.8.2…
remote:        Installing dependencies from Pipfile…
remote:        An error occurred while installing pysocks==1.6.5! Will try again.
remote:        An error occurred while installing pytz==2017.2! Will try again.
remote:        An error occurred while installing pyyaml==3.12! Will try again.
remote:        An error occurred while installing requests==2.12.4! Will try again.
remote:        An error occurred while installing rq-dashboard==0.3.8! Will try again.
remote:        An error occurred while installing selenium==3.0.2! Will try again.
remote:        An error occurred while installing static3==0.7.0! Will try again.
remote:        An error occurred while installing urllib3==1.19.1! Will try again.
remote:        An error occurred while installing user-agents==1.0.1! Will try again.
remote:        An error occurred while installing werkzeug==0.12.2! Will try again.
remote:        An error occurred while installing whitenoise! Will try again.
remote:        An error occurred while installing xmltodict==0.11.0! Will try again.
remote:        Installing initially–failed dependencies…
remote:        Success installing pysocks==1.6.5!
remote:        Success installing pytz==2017.2!
remote:        Success installing pyyaml==3.12!
remote:        Success installing requests==2.12.4!
remote:        Success installing rq-dashboard==0.3.8!
remote:        Success installing selenium==3.0.2!
remote:        Success installing static3==0.7.0!
remote:        Success installing urllib3==1.19.1!
remote:        Success installing user-agents==1.0.1!
remote:        Success installing werkzeug==0.12.2!
remote:        Success installing whitenoise!
remote:        Success installing xmltodict==0.11.0!
remote: -----> $ python manage.py collectstatic --noinput
remote:        Traceback (most recent call last):
remote:          File "manage.py", line 8, in <module>
remote:            from django.core.management import execute_from_command_line
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 13, in <module>
remote:            from django.core.management.base import (
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 17, in <module>
remote:            from django.db.migrations.exceptions import MigrationSchemaMissing
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/__init__.py", line 2, in <module>
remote:            from .operations import *  # NOQA
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/operations/__init__.py", line 1, in <module>
remote:            from .fields import AddField, AlterField, RemoveField, RenameField
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/operations/fields.py", line 2, in <module>
remote:            from django.db.models.fields import NOT_PROVIDED
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/__init__.py", line 19, in <module>
remote:            from django.db.models.manager import Manager
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/manager.py", line 6, in <module>
remote:            from django.db.models.query import QuerySet
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/query.py", line 26, in <module>
remote:            from django.utils.deprecation import RemovedInDjango30Warning
remote:        ImportError: cannot import name 'RemovedInDjango30Warning'
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 myapp.
remote: 
To https://git.heroku.com/myapp.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/myapp.git'

我见过类似问题,如this one,但错误通常是静态文件夹,这不是我的情况。

笔记

  • 如果我在不升级到python 3.6.5的情况下推送应用程序,则不会引发错误。
  • 我最近更换了旧款MacBook。如果我不尝试升级python版本一切正常,我想这无关,但为了以防万一,我认为值得一提。

知道为什么会发生这种情况,我该如何解决?

python django heroku deployment
1个回答
0
投票

不确定原因,但它最终奏效了。

我将尝试解释这里的步骤,以防它帮助其他人。

我等到heroku推荐的最新版本的python是3.6.6而不是3.6.5。

然后我做了以下步骤:

  • 把我的runtime.txt改成了3.6.6
  • 把我的runtime.txt改成了3.7.0
  • 回到runtime.txt3.6.6
  • 删除了我安装的django-lockdown,但我没有使用
  • 在我的本地环境中升级了pip
  • 我跑pip freeze > requirements.txt

我仍然在推送过程中看到了一些错误,但不知何故,这个版本发布了。

remote:        Installing dependencies from Pipfile…
remote:        An error occurred while installing pysocks==1.6.5! Will try again.
remote:        An error occurred while installing pytz==2017.2! Will try again.
remote:        An error occurred while installing pyyaml==3.12! Will try again.
remote:        An error occurred while installing requests==2.12.4! Will try again.
remote:        An error occurred while installing rq==0.7.1! Will try again.
remote:        An error occurred while installing rq-dashboard==0.3.8! Will try again.
remote:        An error occurred while installing selenium==3.0.2! Will try again.
remote:        An error occurred while installing static3==0.7.0! Will try again.
remote:        An error occurred while installing urllib3==1.19.1! Will try again.
remote:        An error occurred while installing user-agents==1.0.1! Will try again.
remote:        An error occurred while installing werkzeug==0.12.2! Will try again.
remote:        An error occurred while installing whitenoise! Will try again.
remote:        An error occurred while installing xmltodict==0.11.0! Will try again.
remote:        Installing initially–failed dependencies…
remote:        Success installing pysocks==1.6.5!
remote:        Success installing pytz==2017.2!
remote:        Success installing pyyaml==3.12!
remote:        Success installing requests==2.12.4!
remote:        Success installing rq==0.7.1!
remote:        Success installing rq-dashboard==0.3.8!
remote:        Success installing selenium==3.0.2!
remote:        Success installing static3==0.7.0!
remote:        Success installing urllib3==1.19.1!
remote:        Success installing user-agents==1.0.1!
remote:        Success installing werkzeug==0.12.2!
remote:        Success installing whitenoise!
remote:        Success installing xmltodict==0.11.0!
© www.soinside.com 2019 - 2024. All rights reserved.