Heroku + gunicorn not working (bash: gunicorn: command not found )

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)
68079 次浏览

Make sure gunicorn is in your requirements.txt

The issue seemed to fix itself after uninstalling all requirements remotely, and reinstalling them.

I was missing the heroku/python buildpack so I went to the dashboard and:

Settings -> Add buildpack -> heroku/python

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.

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

In my case I had an issue inside 'Procfile'.
I removed : after gunicorn.

web: gunicorn: app:app -> web: gunicorn app:app

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!

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.

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

install gunicorn in your virtual environment

pip install gunicorn

then update your requirements.txt file

pip freeze > requirements.txt

add gunicorn in requirements.txt solved my issue.

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/

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.

I was facing the same problem but after adding gunicorn===<latest-version> to requirements.txt file it was fixed.

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.

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

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

install gunicorn in your virtual environment

pip install gunicorn

then update your requirements.txt file

pip freeze > requirements.txt

Add file to github

git add .

Commit

git commit -m "Added gunicorn"

Push back to heroku

git push heroku branch_name:main

I tried this and worked for me

  1. delete gunicorn from requirements.txt

  2. $ pip3 install --user pipenv to install pipenv

  3. $ pipenv install gunicorn to add gunicorn to the pipfile

  4. $ pipenv shell to activate

  5. push