【问题标题】:Heroku: No default language could be detected for this app for python even with runtime.txtHeroku:即使使用 runtime.txt,也无法检测到此 Python 应用程序的默认语言
【发布时间】:2017-10-29 04:49:00
【问题描述】:

我正在尝试将 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:

不知道哪里出错了?

【问题讨论】:

标签: python django git heroku python-3.5


【解决方案1】:

此问题的一个可能解决方案是在应用创建期间指定 buildpack,例如:

$ heroku create myapp --buildpack heroku/python

或在创建应用程序之后:

$ heroku buildpacks:set heroku/python

参考文档:Heroku Docs

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

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

【讨论】:

  • 这给了我App not compatible with buildpack: https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/python.tgz
【解决方案2】:
  1. 在您的 git bash 中:echo "python-3.7.0" > runtime.txt(在根目录中添加 runtime.txt 文件,其中包含 Heroku 使用 python v3.7.0 的说明)
  2. git add .
  3. git commit -am "another commit"
  4. git push heroku master

【讨论】:

    【解决方案3】:

    至于documentation

    如果根目录中存在以下任何文件,Heroku 会自动将您的应用识别为 Python 应用:

    • requirements.txt
    • setup.py
    • Pipfile



    例如,您可以使用pip freeze > requirements.txt 解决这个问题。

    【讨论】:

      猜你喜欢
      • 2018-07-13
      • 1970-01-01
      • 2017-02-13
      • 2017-05-16
      • 2017-09-07
      • 2021-01-23
      • 2021-11-12
      • 2020-12-22
      相关资源
      最近更新 更多