Heroku:python版本问题

krugob8w  于 2022-12-21  发布在  Python
关注(0)|答案(1)|浏览(134)

我尝试在Heroku上部署Django应用,但我遇到了requirements.txt文件的兼容性问题,它指定了"python-3.11.1"。根据Heroku's documentation,Heroku堆栈22支持Python 3.11.1。但每次我尝试使用Heroku CLI部署时,我都会收到错误消息。

-----> Building on the Heroku-22 stack
-----> Using buildpack: heroku/python
-----> Python app detected
-----> Using Python version specified in runtime.txt
Traceback (most recent call last):
  File "/tmp/codon/tmp/buildpacks/0f40890b54a617ec2334fac0439a123c6a0c1136/vendor/runtime-fixer", line 8, in <module>
    r = f.read().strip()
  File "/usr/lib/python3.10/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
/tmp/codon/tmp/buildpacks/0f40890b54a617ec2334fac0439a123c6a0c1136/bin/steps/python: line 9: warning: command substitution: ignored null byte in input
 !     Requested runtime '��python-3.11.1
 !     For supported versions, see: https://devcenter.heroku.com/articles/python-support
 !     Push rejected, failed to compile Python app.
 !     Push failed

我试过了

git push heroku master

我已经按照文档中的构建包检查教程进行了操作:

heroku buildpacks
heroku buildpacks:clear
heroku buildpacks:add heroku/python
nbnkbykc

nbnkbykc1#

我发现了这个问题,我用powershell创建了runtime.txt文件,但是默认情况下它创建的文件是UTF-16 LE编码,而heroku只支持UTF-8/

相关问题