I'm trying to push my repo to my heroku stack but this error comes everytime up:
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/my-heroku-project.git'
This is the full comandline log for Python version 3.8.0:
Enumerating objects: 36, done.
Counting objects: 100% (36/36), done.
Delta compression using up to 8 threads
Compressing objects: 100% (27/27), done.
Writing objects: 100% (36/36), 4.63 MiB | 923.00 KiB/s, done.
Total 36 (delta 9), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: /app/tmp/buildpacks/8790c95df255b386056ea169648fd4a33d1cb3fba81f73b536f26374f6af107145f64a5980db7a52177f63bb41527f360ebd2e3bef7b8917bda7b51cf284cfdb/bin/steps/python: line 5: warning: command substitution: ignored null byte in input
remote: ! Requested runtime (ÿþPython-3.8.0) is not available for this stack (heroku-18).
remote: ! Aborting. More info: https://devcenter.heroku.com/articles/python-support
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to my-heroku-project.
remote:
To https://git.heroku.com/whatsapp-vertretungsplan-bot.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/my-heroku-project.git'
This is the full comandline log for Python version 3.7.5:
Enumerating objects: 40, done.
Counting objects: 100% (40/40), done.
Delta compression using up to 8 threads
Compressing objects: 100% (30/30), done.
Writing objects: 100% (40/40), 4.63 MiB | 910.00 KiB/s, done.
Total 40 (delta 11), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: /app/tmp/buildpacks/8790c95df255b386056ea169648fd4a33d1cb3fba81f73b536f26374f6af107145f64a5980db7a52177f63bb41527f360ebd2e3bef7b8917bda7b51cf284cfdb/bin/steps/python: line 5: warning: command substitution: ignored null byte in input
remote: ! Requested runtime (ÿþPython-3.7.5) is not available for this stack (heroku-18).
remote: ! Aborting. More info: https://devcenter.heroku.com/articles/python-support
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to my-heroku-project.
remote:
To https://git.heroku.com/whatsapp-vertretungsplan-bot.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/my-heroku-project.git'
(This is my first time working with Git and Heroku. So if the error is something obvious I'm sorry.)
The lines that start with "remote:" are echoed by the pre-receive hook in the remote repository. The remote repository runs the hook to check the files before accepting your push. It tries to build/parse the files and encounters an error... You can find the complete answer here. Heroku Deployment Issues ([remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs) .
For my case I was trying to deploy a flask app but was missing a file containing the necessary dependencies. To correct the error I did this to generate a file with all the dependencies. "pip freeze > requirements.txt" and damn.. My problem was solved.
The following blog gives a detailed explanation of how to deploy a Flask app on Heroku. https://medium.com/the-andela-way/deploying-a-python-flask-app-to-heroku-41250bda27d0
How is Python written in the runtime.txt file? Python or python? This problem happened to me: I changed from Python-3.8.0 to python-3.8.0 and it worked.
I found out what the problem was.
I think Heroku didn't support my encoding type, so it added some weird characters to my runtime.txt. But after a change to UTF-8 (I think, it was a long time ago) everything worked fine.
In my case, I realized that had forgotten to log to Heroku via the terminal. Then I updated the requirements.txt
file.
This is what I did:
heroku login
git add.
git commit -m "requirements.txt updates"
git push heroku master.
It worked as I had expected.
For me worked
First
$ heroku config:set DISABLE_COLLECTSTATIC=1
after
$ git push heroku main
I solved it by creating runtime.txt
file and putting the version of python that I want (python-3.7.11) into this file and then placing it the same directory as app.py
:
app.py
Procfile
requirements.txt
runtime.txt
In most cases just disable you static file configuration with this:
heroku config:set DISABLE_COLLECTSTATIC=1
and you'll be good to go.
What worked for me was this pip freeze > requirements.txt
I realised that i had been forgetting to add a requirements file.
After that, repeat the following in order.
git add .
git commit -am "make it better"
git push heroku master
I managed to solve the issue with the following steps:
pip freeze > requirements.txt
git add.
git commit -am "make it better"
Then finally I did the push again:
git push heroku master
remote: -----> Installing requirements with pip
remote: Collecting click==8.0.3
remote: Downloading click-8.0.3-py3-none-any.whl (97 kB)
remote: Collecting Flask==2.0.2
remote: Downloading Flask-2.0.2-py3-none-any.whl (95 kB)
remote: Collecting gunicorn==20.1.0
remote: Downloading gunicorn-20.1.0-py3-none-any.whl (79 kB)
remote: Collecting itsdangerous==2.0.1
remote: Downloading itsdangerous-2.0.1-py3-none-any.whl (18 kB)
remote: Collecting Jinja2==3.0.3
remote: Downloading Jinja2-3.0.3-py3-none-any.whl (133 kB)
remote: Collecting MarkupSafe==2.0.1
remote: Downloading MarkupSafe-2.0.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (30 kB)
remote: Collecting Werkzeug==2.0.2
remote: Downloading Werkzeug-2.0.2-py3-none-any.whl (288 kB)
remote: Installing collected packages: MarkupSafe, Werkzeug, Jinja2, itsdangerous, click, gunicorn, Flask
remote: Successfully installed Flask-2.0.2 Jinja2-3.0.3 MarkupSafe-2.0.1 Werkzeug-2.0.2 click-8.0.3 gunicorn-20.1.0 itsdangerous-2.0.1
remote: -----> Skipping Django collectstatic since the env var DISABLE_COLLECTSTATIC is set.
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing...
remote: Done: 62.3M
remote: -----> Launching...
remote: Released v4
remote: https://flask-heru.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/flask-heru.git
* [new branch] master -> master
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.