Heroku + gunicorn not working (bash: gunicorn: command not found )
HerokuGunicornHeroku Problem Overview
I successfully install gunicorn:
remote: -----> Removing .DS_Store files
remote: -----> Python app detected
remote: -----> Installing dependencies with pip
remote: Collecting gunicorn==19.0.0 (from -r requirements.txt (line 1))
remote: Downloading gunicorn-19.0.0.tar.gz (382kB)
remote: Installing collected packages: gunicorn
remote: Running setup.py install for gunicorn
remote: Successfully installed gunicorn-19.0.0
My Procfile:
web: gunicorn myapp:app --log-file=-
But the app crashes when deployed:
bash: gunicorn: command not found
I tried adding the heroku python buildpack, but no luck. If I roll back to a previous commit (where requirements.txt
and Procile
are both unchanged), it works:
heroku/web.1: Starting process with command `gunicorn myapp:app --log-file=-`
app/web.1: 2015-10-08 17:04:18 [3] [INFO] Listening at: http://0.0.0.0:51854 (3)
Heroku Solutions
Solution 1 - Heroku
Make sure gunicorn
is in your requirements.txt
Solution 2 - Heroku
The issue seemed to fix itself after uninstalling all requirements remotely, and reinstalling them.
Solution 3 - Heroku
I was missing the heroku/python buildpack so I went to the dashboard and:
Settings -> Add buildpack -> heroku/python
Solution 4 - Heroku
If you have both requirements.txt and Pipfile in the project root, then I would recommend to delete the Pipfile and have all your requirements listed in requirements.txt file (including gunicorn).
It will then show: "Installing requirements from pip", and all of your requirements listed in requirements.txt will be installed.
Solution 5 - Heroku
install gunicorn
in your virtual environment
pip install gunicorn
then update your requirements.txt
file
pip freeze > requirements.txt
Solution 6 - Heroku
Heroku's Python docs seem to be outdated... Apparently they now prefer a Pipfile over requirements.txt
, but thankfully you can easily generate one with pipenv
.
Try this:
$ pip3 install --user pipenv
to install pipenv
$ pipenv install gunicorn
to add gunicorn to the pipfile
$ pipenv shell
to activate
I had the exact same error, and this worked for me!
Solution 7 - Heroku
After checking that gunicorn
is in requirements.txt
run:
pip install -r requirements.txt
My output contained several Requirement already satisfied: ...
but gunicorn
wasn't installed:
Collecting gunicorn (from -r requirements.txt (line 2))
Using cached ...
Installing collected packages: gunicorn
Successfully installed gunicorn-19.9.0
Solution 8 - Heroku
In my case, there was a conflict since I had Pipfile
, Pipfile.lock
and requirements.txt
files all at once in the same directory / project.
Heroku was not installing anything from requirements.txt
, hence the same gunicorn error as everyone here.
Solution 9 - Heroku
add gunicorn in requirements.txt solved my issue.
Solution 10 - Heroku
In my case, even though gunicorn was in requirements.txt, gunicorn was not installing because of the Pipfile present. I removed the Pipfile from my github repository and redeployed with success.
The following short tutorial was also helpful to make sure I had the essentials of runtime.txt, wsgi.py, and Procfile configured correctly.
https://www.geeksforgeeks.org/deploy-python-flask-app-on-heroku/
Solution 11 - Heroku
I was facing the same problem but after adding
gunicorn===<latest-version>
to requirements.txt file it was fixed.
Solution 12 - Heroku
In my case I had an issue inside 'Procfile'.
I removed :
after gunicorn
.
web: gunicorn: app:app -> web: gunicorn app:app
Solution 13 - Heroku
You also need to be sure that when running your git push heroku master
that the requirements are installed from requirements.txt and not from pipfile or pipfile.lock. So make sure you remove these files from you cd directory if you are installing your dependencies with requirements.txt
Solution 14 - Heroku
In my case it was because in Pipfile
gunicorn
was under the dev-packages
. Installing it as regular package worked. Only with Pipfile
. No requirements.txt
necessary.
Solution 15 - Heroku
I don't know why it worked, but I was having the same issue, and after reading other suggestions, I ended up deleting my requirements.txt file (even though it had gunicorn) and running pip freeze > requirements.txt
again and it fixed the problem.
Solution 16 - Heroku
In my case, my Heroku app was missing a python buildpack and thus not installing any package.
I fixed this by adding one : Settings
> Buildpacks
> Add buildpack
> python
Solution 17 - Heroku
it happens when gunicorn is Not installed properly... and for insatlling again, installor can only install a file if there is change in requirments.txt
so follow below steps :-
first, install a Empty or only one thing in requirments.txt will make the installor to install something becoz there is change in requirments.txt and follow full complete setps after like git inti .... so on
after that repeat the all steps with full requirments.txt file it will work surely....
mine solved this way.. thanks