Unicode编码错误:部署到Heroku时,'utf-8'编解码器无法解码位置0中字节0xff

wn9m85ua  于 2022-11-13  发布在  其他
关注(0)|答案(3)|浏览(136)

我试着在heroku上部署我的简单django项目,但是我不知道如何解决这个问题
这是一个

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项目的方法,那就太好了

jq6vz3qz

jq6vz3qz1#

整个回溯过程都在括号内:() is not available for this stack。这是当你请求一个不可用的Python运行时显示的消息。在这种情况下,看起来你的runtime.txt甚至因为一个意外的编码而不能被读取。
删除它,然后创建一个新文件,其中包含类似于

python-3.10.2

请确定它是UTF-8编码、认可并重新部署。
目前,这些是当前支持的Python版本,但列表会随着新版本的发布而变化:

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

yuvru6vn2#

当我在Heroku上部署Django应用程序的时候,我遇到了同样的问题。这个问题是因为编码错误。Heroku希望文件用UTF-8保存,但是我意识到我的文件是用UTF-16 le保存的。
因此,如果您正在使用vscode,那么我建议您检查vscode底部的运行时文件的编码。
如果你点击utf-8,你会看到用不同的编码保存文件的选项。否则你也可以用记事本保存文件。记事本使用的默认编码是utf-8
那肯定行。
如果这不能解决问题,请检查其他文件编码

7fyelxc5

7fyelxc53#

非常简单,只需删除runtimeidertxt,并推动代码,这对我来说是有效的。谢谢

相关问题