应用程序与buildpack不兼容 - Heroku

时间:2017-09-08 05:47:59

标签: 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),但它仍然无法正常工作。我怎么解决?

15 个答案:

答案 0 :(得分:7)

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

答案 1 :(得分:5)

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

访问documentation以获得详细说明。

答案 2 :(得分:3)

尝试添加一个名为require.txt的文件 然后输入您需要的任何东西,如Django

答案 3 :(得分:2)

添加pipfile& procfile, &安培; *提交他们,这为我解决了 :)

你可以在这个heroku样本上看到这些文件: link

github上的heroku buildpack: link

答案 4 :(得分:1)

我收到此错误是因为我正在更改其他分支。因此,我当时正在处理功能分支,然后运行 <Container> <Navbar light expand="md" className="navbar-style"> <NavbarToggler onClick={this.toggle} /> <NavbarBrand className="logo" href="/"> <img src="https://res.cloudinary.com/candidbusiness/image/upload/v1455406304/dispute-bills-chicago.png" /> </NavbarBrand> <NavbarBrand href="/">The Big brand title will be displayed here !</NavbarBrand> <Collapse isOpen={this.state.isOpen} navbar> <Nav className="ml-auto" navbar> {links.map(createNavItem)} </Nav> </Collapse> <Nav className="ml-auto cart" navbar> <NavItem className="cart-wrapper"> <Button className="cart-style" color="primary" size="sm"> Cart </Button> <Badge className="badge-style"> 10 </Badge> </NavItem> </Nav> </Navbar> </Container> 。我的更改尚未合并到我的master分支中,因此出现了错误。合并到Procfile中后,我便可以将更改推送到heroku。

答案 5 :(得分:1)

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

答案 6 :(得分:1)

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

答案 7 :(得分:1)

你可以试试:

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

答案 8 :(得分:0)

运行此命令:

heroku buildpacks:set heroku/python

您也可以参考this文件。

答案 9 :(得分:0)

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

CLI安装

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

答案 10 :(得分:0)

  

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

例如: heroku buildpacks:set heroku/nodejs

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

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

  

步骤2)git init和当前使用的目录是    不同 ,因此仍会引发此错误“应用程序与buildpack不兼容:”

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

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

C:/sample_folder/nodejs_app/package.json

  

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

git push heroku master

-编码愉快!

答案 11 :(得分:0)

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

  1. 激活您的虚拟环境。

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

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

答案 12 :(得分:0)

第一个文件:requirements.txt,其中包含以下内容:gunicorn == 19.7.1或任何点子冻结结果> requirements.txt都是

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

然后git add。和git commit -m“添加了Procfile和requirements.txt”。

然后运行git push heroku master从本地master分支推送到heroku远程。

分享编辑关注

答案 13 :(得分:0)

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

答案 14 :(得分:0)

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

相关问题