繁体   English   中英

应用与 buildpack 不兼容 - Heroku

[英]App not compatible with buildpack - Heroku

当我运行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),但它仍然不起作用。 我该如何解决?

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

访问文档以获取详细说明。

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

添加pipfile和procfile,并提交它们,这为我解决了:)

您可以在此 heroku 示例中看到我所说的文件:链接

github上的heroku buildpack:链接

尝试添加一个名为 requirements.txt 的文件并输入您需要的任何内容,例如 django

步骤 1)首先设置 buildpack(编程语言)

例如: heroku buildpacks:set heroku/nodejs

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

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

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

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

但是modules 和 package.json位于嵌套的子文件夹下:-

C:/sample_folder/nodejs_app/package.json

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

git push heroku master

--快乐编码!

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

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

你可以尝试这样做:

  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 项目的根目录中 :)

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

您可以通过此方法为python指定buildpack

命令行安装

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

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

  1. 激活您的虚拟环境。

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

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

第一个文件: requirements.txt

包含以下内容: gunicorn==19.7.1pip freeze > requirements.txt任何结果。

第二个文件: Procfile

包含以下内容: web: gunicorn app:app或可能为空白。 请注意,本示例中的app:app是对您的 Python 文件名的引用。 这意味着每次声明 Web 进程并启动gunicorn app:app ,还要运行命令gunicorn app:app来启动您的 Web 服务器。

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

然后运行git push heroku masterlocal master分支推送到heroku remote

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

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

-> 确保您的 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

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

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

运行此命令:

heroku buildpacks:set heroku/python

你也可以参考这个文件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM