Heroku Python远程拒绝错误

问题描述 投票:1回答:3

我正在制作一个简单的Python机器人,它可以像python file.py一样运行。我在我的电脑上创建了一个文件夹,其中包含3个文件file.py list.txt Procfile。在Procfile中我编写了worker: python file.py,我选择了worker作为命令行应用程序,我的计划是永远在服务器上运行该Python文件。比我做git initheroku git:remote -a py-bot-xyz其中py-bot-xyz是我在My Heroku仪表板中创建的应用程序,而不是git add .git commit -am "make it better"和最后git push heroku master

这就是错误发生的地方,打印出来


    remote: Compressing source files... done.
    remote: Building source:
    remote: 
    remote: 
    remote:  !     Push rejected, no Cedar-supported app detected
    remote: HINT: This occurs when Heroku cannot detect the buildpack
    remote:       to use for this application automatically.
    remote: See https://devcenter.heroku.com/articles/buildpacks
    remote: 
    remote: Verifying deploy....
    remote: 
    remote: !   Push rejected to py-bot-xyz.
    remote: 
    To https://git.heroku.com/py-bot-xyz.git
     ! [remote rejected] master -> master (pre-receive hook declined)
    error: failed to push some refs to 'https://git.heroku.com/py-bot-xyz.git'

现在,当我去Heroku的Dashboard Build失败的活动。我现在能做什么? :(((

python git heroku deployment
3个回答
1
投票

每个Heroku buildpack都应用不同的测试来确定它是否适用。对于Python,buildpack会查找'requirements.txt'或'setup.py'文件(请参阅https://github.com/heroku/heroku-buildpack-python/blob/master/bin/detect)。如果您没有其中一个文件,可以通过heroku buildpacks:set heroku/python明确设置。见https://devcenter.heroku.com/articles/buildpacks#setting-a-buildpack-on-an-application


1
投票

要成功将python代码推送到heroku,您应该有一个requirements.txt和一个Procfile。转到终端/命令行中的项目文件夹,然后输入以下命令,这些命令将生成必要的文件。提交他们并推动应该工作。

  1. pip freeze > requirements.txt(你可能需要安装pip,如果使用旧的python版本)
  2. echo "worker: python yourfile.py" > Procfileworker可以用web代替,如果它是一个网站)

0
投票

我面临着同样的错误。因为我是这个领域的新手..我使用“requirement.txt”而不是“requirements.txt”。

注意确切的拼写。

© www.soinside.com 2019 - 2024. All rights reserved.