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

2024-04-29 07:20:46 发布

您现在位置:Python中文网/ 问答频道 /正文

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

不知道我错在哪里?


Tags: tohttpsprojectcomsourceherokuobjectsremote
2条回答

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

$ heroku create myapp --buildpack heroku/python

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

$ heroku buildpacks:set heroku/python

参考文档:Heroku Docs

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

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

  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

相关问题 更多 >