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

时间:2017-05-28 23:30:34

标签: python django git heroku python-3.5

我正在尝试将project部署到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...

如果你去我的github project,我拥有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:

不确定我哪里出错了?

2 个答案:

答案 0 :(得分:3)

此问题的可能解决方案是在应用创建过程中指定buildpack,如:

$ heroku create myapp --buildpack heroku/python

或创建应用后,如:

$ heroku buildpacks:set heroku/python

参考文档:Heroku Docs

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

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

答案 1 :(得分:0)

  1. 在git bash中:STRING(在根目录中添加runtime.txt文件,并附有Heroku使用python v3.7.0的说明)
  2. Substring
  3. echo "python-3.7.0" > runtime.txt
  4. git add .