UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0 when deploying to Heroku

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0 when deploying to Heroku

我试图在 heroku 上部署我的简单 django 项目,但我不明白如何解决这个问题

这是git push heroku master

remote: Traceback (most recent call last):
remote:   File "/tmp/codon/tmp/buildpacks/0f40890b54a617ec2334fac0439a123c6a0c1136/vendor/runtime-fixer", line 8, in <module>
remote:     r = f.read().strip()
remote:   File "/usr/lib/python3.8/codecs.py", line 322, in decode
remote:     (result, consumed) = self._buffer_decode(data, self.errors, final)
remote: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
remote: /tmp/codon/tmp/buildpacks/0f40890b54a617ec2334fac0439a123c6a0c1136/bin/steps/python: line 5: warning: command substitution: ignored null byte in input
remote: ) is not available for this stack (heroku-20).
remote:  !     Aborting.  More info: https://devcenter.heroku.com/articles/python-support
remote:  !     Push rejected, failed to compile Python app.
remote:
remote:  !     Push failed
remote:  !
remote:  ! ## Warning - The same version of this code has already been built: 898dd95ff261fc77ac4dcd00edd162d7b7c054f2
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version 898dd95ff261fc77ac4dcd00edd162d7b7c054f2
remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote:  !
remote:  ! If you are developing on a branch and deploying via git you must run:
remote:  !
remote:  !     git push heroku <branchname>:main
remote:  !
remote:  ! This article goes into details on the behavior:
remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: !       Push rejected to portfolio-project10.
remote:
To https://git.heroku.com/portfolio-project10.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/portfolio-project10.git'

C:...\portfolio-project>

如果有人能帮我解决这个问题,甚至推荐其他免费部署 django 项目的方法,那就太好了

整个回溯都在这些括号内:() is not available for this stack。这是当您请求不可用的 Python 运行时时显示的消息。在这种情况下,由于意外编码,您的 runtime.txt 似乎甚至无法读取。

删除它,然后创建一个包含类似内容的新文件

python-3.10.2

只有。确保它是 UTF-8 编码的,提交并重新部署。

目前,这些是当前支持的 Python 版本,但是 the list changes as new versions are released:

  • python-3.10.2
  • python-3.9.10
  • python-3.8.12
  • python-3.7.12