Heroku:即使使用runtime.txt,也无法为此python应用程序检测到默认语言

pyt*_*hon 9 python git django heroku python-3.5

我正在尝试将项目部署到heroku,我收到此错误: -

Counting objects: 70, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (64/64), done.
Writing objects: 100% (70/70), 17.36 KiB | 0 bytes/s, done.
Total 70 (delta 23), reused 3 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote:  !     No default language could be detected for this app.
remote:             HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
remote:             See https://devcenter.heroku.com/articles/buildpacks
remote:
remote:  !     Push failed
remote: Verifying deploy...
Run Code Online (Sandbox Code Playgroud)

如果你去我的github 项目,我有heroku项目所需的一切,包括runtime.txt文件,但我仍然收到此错误.我尝试更改Heroku支持的不同python版本,但仍然是同样的错误.任何人都可以帮我吗?

如果我添加一个buildpack,那么我收到以下错误

Counting objects: 70, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (64/64), done.
Writing objects: 100% (70/70), 17.36 KiB | 0 bytes/s, done.
Total 70 (delta 23), reused 3 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Failed to detect app matching https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/python.tgz buildpack
remote:        More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
Run Code Online (Sandbox Code Playgroud)

不知道我哪里出错了?

Raj*_*han 5

此问题的可能解决方案是在应用程序创建期间指定构建包,例如:

$ heroku create myapp --buildpack heroku/python
Run Code Online (Sandbox Code Playgroud)

或者在创建应用程序后,例如:

$ heroku buildpacks:set heroku/python
Run Code Online (Sandbox Code Playgroud)

参考文档:Heroku 文档

我发现的另一个问题是package.json我的 django 项目中有不必要的文件和其他文件。我通过从应用程序目录中删除不必要的文件解决了这个问题。
由于这些文件阻碍了 buildpack 的自动检测。

检测失败的另一个原因可能是应用程序的文件夹结构错误。Procfile其他 heroku 文件应该位于 git 目录的开头,否则您的应用程序将不会被检测到。

  • 这给了我“应用程序与 buildpack 不兼容:https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/python.tgz” (8认同)