我阅读了之前所有关于它的帖子,但仍然无法更正它。我在 Heroku 创建的计算机目录中添加了 requirements.txt 和 Procfile。 Procfile 显示为“web: python Chat Server.py”。还在读取“python-3.6.2”的同一目录中添加了 runtime.txt。但是,它在命令提示符下再次出现相同的错误。我该如何解决这个问题?这是完整的错误消息:
"C:\Users\asus\chat_server>git push heroku master 数对象:6个,完成。 使用最多 4 个线程的增量压缩。 压缩对象:100% (4/4),完成。 写入对象:100% (6/6),1.14 KiB | 585.00 KiB/s,完成。 共 6 个(delta 1),重复使用 0 个(delta 0) 远程:压缩源文件...完成。 远程:建筑来源: 偏僻的: 远程:-----> 应用程序与 buildpack 不兼容:https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/python.tgz 远程:更多信息:https://devcenter.heroku.com/articles/buildpacks#detection-failure 偏僻的: 偏僻的: !推送失败 远程:验证部署... 偏僻的: 偏僻的: !将拒绝推送到 boiling-stream-15219。 偏僻的: 至https://git.heroku.com/boiling-stream-15219.git ! [remote rejected] master -> master(pre-receive hook declined) 错误:无法将某些引用推送到“https://git.heroku.com/boiling-stream-15219.git” ' "
最佳答案
任何阅读本文的人:您需要两个文件:
第一个文件:
requirements.txt
包含如下内容:
gunicorn==19.7.1
或 pip freeze > requirements.txt
的任何结果。
第二个文件:
Procfile
包含如下内容:
web: gunicorn app:app
或可能为空白。请注意,此示例中的 app:app
是对您的 python 文件名的引用。这意味着每次声明 web
进程并启动此类 dyno 时,还要运行命令 gunicorn app:app
以启动您的 Web 服务器。
然后 git add .
和 git commit -m "added Procfile and requirements.txt"
.
然后运行 git push heroku master
从本地 master
分支推送到 heroku
远程。
关于Python heroku -app 与 buildpack 不兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48341454/