【问题标题】:Heroku/Django - No default language could be detected for this appHeroku/Django - 无法检测到此应用程序的默认语言
【发布时间】:2022-01-11 23:00:02
【问题描述】:

我第一次尝试通过 Heroku 部署 Django 应用程序。

当我运行git push heroku master 时,它会返回此错误:

remote: -----> Building on the Heroku-20 stack
remote: -----> Determining which buildpack to use for this app
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:  !
remote:  ! ## Warning - The same version of this code has already been built: e6acd22b123b939729546f4f06f368a8855a4744
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version e6acd22b123b939729546f4f06f368a8855a4744
remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote:  !
remote:  ! If you are developing on a branch and deploying via git you must run:
remote:  !
remote:  !     git push heroku <branchname>:main
remote:  !
remote:  ! This article goes into details on the behavior:
remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
remote: 
remote: Verifying deploy...
remote: 
remote: !       Push rejected to vygrapp.
remote: 
To https://git.heroku.com/vygrapp.git
 ! [remote rejected] master -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/vygrapp.git'

在 SO 上遇到类似问题后,我相信我的文件结构已正确配置 - git 从与我的 Procfile 等相同的位置部署。我还有一个 requirements.txt 文件,我相信它告诉 Heroku 这是一个 python 应用程序 - 所以我可以'不知道为什么 buildpack 不工作。

根据 cmets 和反馈,我将所有文件夹移至根目录,但收到相同的错误。

【问题讨论】:

    标签: django heroku


    【解决方案1】:

    Heroku 仅在项目的根目录中查找您的 Procfilerequirements.txtruntime.txt。将它们上移一级,使其位于您的 .gitattributes 旁边。

    这应该让 Heroku 检测到这是一个 Python 项目并克服当前错误。

    但您的项目仍然无法运行。开箱即用,Heroku 将期望您的 Django 项目位于存储库的根目录中。您可能可以通过使用DJANGO_SETTINGS_MODULE 环境变量和/或PYTHONPATH 来使其从子目录中运行,但最简单的解决方案是将整个项目移到一个目录中。

    我建议您将所有内容从anybody/anybody1/ 移至anybody/,然后删除现在为空的anybody/anybody1/ 目录。

    然后提交并重新部署。

    【讨论】:

    • 感谢您的回复 - 我已按照您的指示删除了 anybody1 目录 - 尽管其中还保留了 settings 等目录。这是我的目录looks like now。但是仍然会抛出错误。
    • 您遇到了 same 错误?哪个目录包含您的 .git/ 文件夹?
    • 感谢您的回复! Here 是我的文件夹结构,.git/ 未隐藏 - 你可以看到不同目录中有两个 .git/ 文件夹 - 可能是冲突?为截图道歉,有点不雅。
    • Nesting Git repositories probably doesn't do what you think it does。无论如何,您要将哪个存储库推送到 Heroku?
    • 抱歉我的无知 - 我如何检查这个?第一次部署。
    猜你喜欢
    • 2017-02-13
    • 2017-09-07
    • 2017-10-29
    • 2017-05-16
    • 2020-12-22
    • 2021-01-23
    • 2021-11-12
    • 2018-02-22
    相关资源
    最近更新 更多