简体   繁体   中英

Uploading a Django project on Heroku Server

I uploaded my Django project to Heroku and I get this error message on the browser as shown on the screenshot

在此处输入图像描述

But when I check the log on the admin I see this message below:

2019-05-14T21:26:26.138333+00:00 app[web.1]: bash: gunicorn: command not found

But gunicorn is included in my requirements.txt file:

dj-database-url==0.5.0
Django==2.2.1
django-heroku==0.3.1
gunicorn==19.9.0
psycopg2==2.8.2
pytz==2019.1
sqlparse==0.3.0
whitenoise==4.1.2

I also have a Pipfile and Pipfile.lock .

Why can't Heroku find gunicorn ?

Generally speaking, you should use either requirements.txt or Pipfile and Pipfile.lock . They do roughly the same thing, but work with different tooling.

Pipfile and Pipfile.lock are a newer standard. If they are present, Heroku installs dependencies using Pipenv . In this case the requirements.txt file is ignored.

You should either

  1. Choose to use Pipenv.

    1. Your requirements may already be listed in the Pipfile and Pipfile.lock , but run pipenv install -r requirements.txt locally just to be sure.
    2. Delete your requirements.txt with git rm requirements.txt .
    3. Commit this change, eg git commit -m 'Switch from pip to Pipenv' .
    4. Push to Heroku.
  2. Choose to use pip .

    1. Read your Pipfile to see if there's anything in there you might need. This file does more than just list dependencies.

      For example, your Pipfile may specify a required Python version like python_version = '3.7' in the [requires] section. This can't be represented in requirements.txt , so you'll need to create a runtime.txt file to specify your Python version.

      You might also want to create a second requirements file for development dependencies.

    2. Delete the Pipfile and Pipfile.lock with git rm Pipfile Pipfile.lock .

    3. Commit, eg git commit -m 'Revert from Pipenv to pip .

    4. Push to Heroku.

I uploaded my Django project to Heroku and I get this error message on the browser as shown on the screenshot

在此处输入图片说明

But when I check the log on the admin I see this message below:

2019-05-14T21:26:26.138333+00:00 app[web.1]: bash: gunicorn: command not found

But gunicorn is included in my requirements.txt file:

dj-database-url==0.5.0
Django==2.2.1
django-heroku==0.3.1
gunicorn==19.9.0
psycopg2==2.8.2
pytz==2019.1
sqlparse==0.3.0
whitenoise==4.1.2

I also have a Pipfile and Pipfile.lock .

Why can't Heroku find gunicorn ?

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM