【问题标题】:App not compatible with buildpack - Heroku应用程序与 buildpack 不兼容 - Heroku
【发布时间】:2018-02-16 23:11:19
【问题描述】:

当我运行git push heroku master 时,我得到了:

C:\Users\Emanuele-PC\Desktop\project-mm-beta>git push heroku master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 505 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> App not compatible with buildpack: https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/python.tgz
remote:        More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to project-mm-beta.
remote:
To https://git.heroku.com/project-mm-beta.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/project-mm-beta.git'

我尝试部署的代码只是一个文件(这是一个测试,因为这是我第一次使用 Heroku),它是用 Python 编写的。我已经设置了 buildpack (python),但它仍然不起作用。我该如何解决?

【问题讨论】:

  • 您需要包含一个requirements.txt 文件。它可以是空的。 devcenter.heroku.com/articles/python-runtimes#activation-1
  • 我做到了,但我仍然收到该错误。
  • 如果您运行heroku logs,是否会显示任何其他错误
  • 只有这种错误:2017-09-08T06:18:27.000000+00:00 app[api]: Build failed -- check your build logs在不同时间重复(只有这种错误,没有其他错误)。但我认为这与“App 与 buildpack 不兼容”有关。
  • 也许添加一个像stackoverflow.com/a/44854965/6085135这样的Procfile

标签: heroku


【解决方案1】:

检查您是否编写了正确的 Procfile 和 requirements.txt 拼写,因为它们区分大小写,在我的情况下,将 procfile 更改为 Procfile 后它开始正常工作。

【讨论】:

    【解决方案2】:

    我刚刚从连接到我的 Heroku 应用程序的 GitHub 存储库中删除了 README.md,这对我有用!

    【讨论】:

      【解决方案3】:

      -> 确保您的 requirements.txt 和 Procfile 在根文件夹中。

      -> 如果您不在 master 分支中,请运行以下命令。

      git checkout -b master
      git add .
      git commit -m "your commit message"
      git push -u origin master
      git push heroku master
      

      【讨论】:

        【解决方案4】:

        我遇到了同样的问题。只需确保您在 django 项目根目录中初始化了 git repo。这样一来,您的 .git 文件夹、.gitignore 文件、manage.py、requirements.txt 等都处于同一层次。

        【讨论】:

        • 这个解决方案对我有用
        【解决方案5】:

        你可以试试:

        1. pip3 freeze > requirements.txt
        2. heroku buildpacks:set heroku/python
        3. git add .; git commit -m "add requirements.txt"; git push heroku master

        注意:确保您位于 Python 项目的根目录中:)

        【讨论】:

          【解决方案6】:

          第一个文件: requirements.txt

          包含类似:gunicorn==19.7.1pip freeze > requirements.txt 的任何结果。

          第二个文件: Procfile

          包含类似:web: gunicorn app:app 或可能为空白的内容。请注意,此示例中的 app:app 是对您的 python 文件名的引用。这意味着每次声明一个 web 进程,并启动一个这种类型的 dyno 时,还要运行命令 gunicorn app:app 来启动你的 web 服务器。

          然后是git add .git commit -m "added Procfile and requirements.txt"

          然后运行git push heroku master 以从您的local master 分支推送到heroku remote

          【讨论】:

          • 很高兴你已经回答了这个问题,但你能解释清楚吗?使这一点更清晰的一种方法是将事物格式化为代码。您可以使用反引号` 来做到这一点
          【解决方案7】:

          好吧,当我第一次创建 Heroku 应用程序时,我也遇到了同样的情况。 只需添加requirements.txt。它会正常工作的。

          【讨论】:

            【解决方案8】:

            最后确保你没有从你的 .gitignore 中忽略 requirements.txt,这是我的问题。

            【讨论】:

              【解决方案9】:

              我遇到了同样的错误,因为我没有提交文件,确保在更改任何文件后运行命令 git add . 然后 git commit -m'message',然后你可以 run git push heroku master 并添加 requirements.txtProcfile 正确。

              【讨论】:

                【解决方案10】:

                检查您是否执行了以下步骤:

                1. 激活您的虚拟环境。

                2. 在命令提示符下运行:
                  pip freeze>requirements.txt

                3. 在您的主应用程序目录中添加Procfile(与manage.py 所在的位置相同);
                  您应该在Procfile 中插入:
                  web: gunicorn your_app_name.wsgi

                【讨论】:

                • 糟糕,你拼错了requirements.txt
                【解决方案11】:

                添加 pipfile & procfile, & commit 他们,这为我解决了 :)

                您可以在这个 heroku 示例中看到我所说的文件: link

                github上的heroku buildpack: link

                【讨论】:

                • 拍脑门忘记提交,输了半个小时。
                【解决方案12】:

                尝试添加一个名为 requirements.txt 的文件 并输入你需要的任何东西,比如 django

                【讨论】:

                • OP 在 cmets 中指出,当存在 requirements.txt 文件时,此错误一直存在。
                【解决方案13】:

                我收到此错误是因为我正在对不同的分支进行更改。所以我在一个功能分支上工作,然后运行git push heroku master。我的更改尚未合并到我的主分支中,因此出现了错误。一旦我将 Procfile 合并为 master,我就能够将更改推送到 heroku。

                【讨论】:

                  【解决方案14】:

                  我刚刚发现...这是一个非常愚蠢的问题。确保 git repo 在项目根文件夹中初始化。假设项目是一个 Django 应用程序,由 Django 创建的项目文件夹是 my-project,则需要在 my-project 内初始化 git repo 才能使 Heroku 工作...

                  【讨论】:

                  • repo 需要在根目录中“初始化”是什么意思。我知道根在哪里,但不知道在特定文件夹中初始化 git repo 的意思。
                  • 我的意思是项目根文件夹。我也以my-project 为例进行了解释。
                  • 我正在构建烧瓶应用程序,但对我不起作用
                  • 同样的事情发生在我身上
                  【解决方案15】:

                  步骤 1) 首先设置 buildpack (programming-language)

                  例如:heroku buildpacks:set heroku/nodejs

                  在这里查看更多信息:https://devcenter.heroku.com/articles/buildpacks

                  如果问题仍然存在,请执行下一步

                  步骤 2) git init 和当前使用的目录是 不同,所以还是会抛出这个错误"App not compatible with buildpack:"

                  例如:git init 命令在以下位置执行:- C:/sample_folder/

                  modules 和 package.jsonnested 子文件夹下:-

                  C:/sample_folder/nodejs_app/package.json

                  因此,相应地移动文件,使所有文件存在于同一文件夹下 然后运行

                  git push heroku master

                  --愉快的编码!

                  【讨论】:

                  • 这非常有帮助;这是唯一一篇包含“你必须确保你的 git 在正确的位置”的帖子。 +1。
                  【解决方案16】:

                  你可以通过这个方法为python指定buildpack

                  CLI 安装

                  heroku buildpacks:set https://github.com/heroku/heroku-buildpack-python.git
                  

                  【讨论】:

                    【解决方案17】:

                    只有当应用程序的根目录中有 Pipfile 或 requirements.txt 时,Heroku Python 支持才会应用于应用程序。

                    访问documentation获取详细说明。

                    【讨论】:

                      【解决方案18】:

                      运行这个命令:

                      heroku buildpacks:set heroku/python
                      

                      也可以参考this文档。

                      【讨论】:

                      • 这只是说:The buildpack heroku/python is already set on your app.
                      猜你喜欢
                      • 1970-01-01
                      • 2020-10-03
                      • 2018-01-22
                      • 2021-11-12
                      • 1970-01-01
                      • 1970-01-01
                      • 2019-02-05
                      相关资源
                      最近更新 更多