Heroku Python Remote Rejected error

蹲街弑〆低调 提交于 2019-12-13 11:52:22

问题


I am making a Simple Python Bot which can be run like python file.py . I created a Folder in my PC having 3 files file.py list.txt Procfile . In Procfile i wrote worker: python file.py , I choosed worker as it a Command Line application and my plan is to run that Python File forever on the server. Than i did git init , heroku git:remote -a py-bot-xyz where py-bot-xyz is the application which i created in My Heroku Dashboard and than git add ., git commit -am "make it better" & finally git push heroku master .

That's where the error occurs, that prints out


    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'

Now, when i go to Heroku's Dashboard Build Failed in Activity. What can i do now? :(((


回答1:


To successfully push python code to heroku you should have a requirements.txt and a Procfile. Go to your project folder in terminal/commandline and enter the following commands which will generate the necessary files. Commit them and push should work.

  1. pip freeze > requirements.txt(you might need to install pip, if using older python version)

  2. echo "worker: python yourfile.py" > Procfile (worker could be replaced with web if it's a website)




回答2:


Each Heroku buildpack applies different tests to determine if it applies. For Python, the buildpack looks for a 'requirements.txt' or 'setup.py' file (see https://github.com/heroku/heroku-buildpack-python/blob/master/bin/detect). If you don't have one of those files, you can set it explicitly via heroku buildpacks:set heroku/python. See https://devcenter.heroku.com/articles/buildpacks#setting-a-buildpack-on-an-application




回答3:


I was facing same kind of error. As I am new to this area.. I used "requirement.txt" instead of "requirements.txt".

Watch out for the exact spellings.



来源:https://stackoverflow.com/questions/37899247/heroku-python-remote-rejected-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!