简体   繁体   中英

Python/Flask/Gunicorn to Heroku

This was all working up until this morning. I have no idea why it no longer works. It will run with heroku local but when I deploy, it doesn't work.

Requirements.txt includes gunicorn==19.7.1 Profile: web: gunicorn --bind 0.0.0.0:$PORT app:app

But heroku logs say: 2018-05-10T17:05:52.180162+00:00 heroku[web.1]: Process exited with status 127 2018-05-10T17:05:52.126101+00:00 app[web.1]: bash: gunicorn: command not found

Any ideas?!

Edited per request.... Pipfile:

[requires]
python_full_version = "2.7.15"

Pipfile.lock:

{
    "_meta": {
        "hash": {
            "sha256": "ddf17106580f080dfb1396654a2d3915f6eb52c46f4097c409cb3b1205ec403c"
        },
        "pipfile-spec": 6,
        "requires": {
            "python_full_version": "2.7.15"
        },
        "sources": [
            {
                "name": "pypi",
                "url": "https://pypi.python.org/simple",
                "verify_ssl": true
            }
        ]
    },
    "default": {},
    "develop": {}
}

Here are the logs. Is this what you need? Thanks for the help!

$ heroku logs
2018-05-10T21:07:57.901810+00:00 heroku[web.1]: Starting process with command `python app.py`
2018-05-10T21:08:00.042609+00:00 heroku[web.1]: Process exited with status 1
2018-05-10T21:08:00.084437+00:00 heroku[web.1]: State changed from starting to crashed
2018-05-10T21:07:59.956948+00:00 app[web.1]: Traceback (most recent call last):
2018-05-10T21:07:59.956967+00:00 app[web.1]:   File "app.py", line 1, in <module>
2018-05-10T21:07:59.956975+00:00 app[web.1]:     from flask import Flask, render_template, url_for, request, session, redirect, jsonify, json, flash
2018-05-10T21:07:59.956976+00:00 app[web.1]: ImportError: No module named flask
2018-05-10T21:08:47.000000+00:00 app[api]: Build started by user alecdown@gmail.com
2018-05-10T21:08:54.680145+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=studentsrm.herokuapp.com request_id=460372a5-6641-44b0-a509-480814c6314a fwd="155.98.26.248" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T21:08:54.953954+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=studentsrm.herokuapp.com request_id=16306630-95bf-4913-abc3-b568309bf0d7 fwd="155.98.26.248" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T21:09:00.281872+00:00 heroku[web.1]: State changed from crashed to starting
2018-05-10T21:08:59.929228+00:00 app[api]: Release v7 created by user alecdown@gmail.com
2018-05-10T21:08:59.929228+00:00 app[api]: Deploy d7acedd1 by user alecdown@gmail.com
2018-05-10T21:08:47.000000+00:00 app[api]: Build succeeded
2018-05-10T21:09:04.721843+00:00 heroku[web.1]: Starting process with command `python app.py`
2018-05-10T21:09:07.217753+00:00 heroku[web.1]: Process exited with status 1
2018-05-10T21:09:07.266290+00:00 heroku[web.1]: State changed from starting to crashed
2018-05-10T21:09:07.127011+00:00 app[web.1]: Traceback (most recent call last):
2018-05-10T21:09:07.127035+00:00 app[web.1]:   File "app.py", line 1, in <module>
2018-05-10T21:09:07.127038+00:00 app[web.1]:     from flask import Flask, render_template, url_for, request, session, redirect, jsonify, json, flash
2018-05-10T21:09:07.127041+00:00 app[web.1]: ImportError: No module named flask
2018-05-10T21:09:08.724431+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=studentsrm.herokuapp.com request_id=d9d42e43-dfd1-4460-89e4-96947ad59c84 fwd="155.98.26.248" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T21:09:08.927890+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=studentsrm.herokuapp.com request_id=dc35f7ec-2546-4e37-9117-9de54f6f7fb9 fwd="155.98.26.248" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T21:10:42.041785+00:00 app[api]: Starting process with command `bash` by user tk@heroku.com
2018-05-10T21:10:47.349507+00:00 heroku[run.7135]: State changed from starting to up
2018-05-10T21:10:47.224141+00:00 heroku[run.7135]: Awaiting client
2018-05-10T21:10:47.286860+00:00 heroku[run.7135]: Starting process with command `bash`
2018-05-10T21:12:38.169070+00:00 heroku[run.7135]: State changed from up to complete
2018-05-10T21:12:38.132500+00:00 heroku[run.7135]: Process exited with status 0
2018-05-10T21:12:40.484080+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=studentsrm.herokuapp.com request_id=6f30f7fa-a596-410a-8c30-fb997d21d270 fwd="155.98.26.248" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T21:12:41.147917+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=studentsrm.herokuapp.com request_id=e9f9ac9a-6d14-4467-9838-1265cb664d00 fwd="155.98.26.248" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T21:12:48.813788+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=studentsrm.herokuapp.com request_id=80620f61-3bbd-4671-adb0-4064a9585c4f fwd="155.98.26.248" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T21:12:49.147215+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=studentsrm.herokuapp.com request_id=163f502c-210b-4956-8f2f-5f4500175e4f fwd="155.98.26.248" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T21:12:54.477489+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=studentsrm.herokuapp.com request_id=c2bed499-77fb-4ca7-b761-2c40f360cd57 fwd="155.98.26.248" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T21:12:54.768354+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=studentsrm.herokuapp.com request_id=48cee808-8178-454f-b6bb-a044920a7353 fwd="155.98.26.248" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T21:12:57.775487+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=studentsrm.herokuapp.com request_id=3d87f7db-e69e-4447-9fd8-dda75a0a7f72 fwd="155.98.26.248" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T21:12:58.163382+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=studentsrm.herokuapp.com request_id=4bd5d918-32ef-44d4-918c-d66bbd7e31d9 fwd="155.98.26.248" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T21:13:04.157154+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=studentsrm.herokuapp.com request_id=0b3ba795-827f-4d5d-b029-16abc9f51854 fwd="155.98.26.248" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T21:13:04.556643+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=studentsrm.herokuapp.com request_id=c41e6643-eb24-4c08-b896-7027fd5a3590 fwd="155.98.26.248" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T21:28:40.011239+00:00 heroku[web.1]: State changed from crashed to starting
2018-05-10T21:28:44.212653+00:00 heroku[web.1]: Starting process with command `python app.py`
2018-05-10T21:28:46.532487+00:00 heroku[web.1]: State changed from starting to crashed
2018-05-10T21:28:46.507017+00:00 heroku[web.1]: Process exited with status 1
2018-05-10T21:28:46.451278+00:00 app[web.1]: Traceback (most recent call last):
2018-05-10T21:28:46.451297+00:00 app[web.1]:   File "app.py", line 1, in <module>
2018-05-10T21:28:46.451306+00:00 app[web.1]:     from flask import Flask, render_template, url_for, request, session, redirect, jsonify, json, flash
2018-05-10T21:28:46.451308+00:00 app[web.1]: ImportError: No module named flask
2018-05-10T21:44:26.551990+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=studentsrm.herokuapp.com request_id=e16d1800-f61a-43ab-acdc-a6595cd8a8fe fwd="155.98.26.248" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T21:44:26.832924+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=studentsrm.herokuapp.com request_id=8e28982f-2193-4bd1-9eb2-43e05f96ba21 fwd="155.98.26.248" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T21:44:27.243184+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=studentsrm.herokuapp.com request_id=ccb0d623-c9c9-48f6-b384-a2ef57d58907 fwd="155.98.26.248" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T22:05:18.124970+00:00 heroku[web.1]: State changed from crashed to starting
2018-05-10T22:05:21.714142+00:00 heroku[web.1]: Starting process with command `python app.py`
2018-05-10T22:05:23.948792+00:00 app[web.1]: Traceback (most recent call last):
2018-05-10T22:05:23.948809+00:00 app[web.1]:   File "app.py", line 1, in <module>
2018-05-10T22:05:23.948817+00:00 app[web.1]:     from flask import Flask, render_template, url_for, request, session, redirect, jsonify, json, flash
2018-05-10T22:05:23.948818+00:00 app[web.1]: ImportError: No module named flask
2018-05-10T22:05:24.004641+00:00 heroku[web.1]: Process exited with status 1
2018-05-10T22:05:24.483293+00:00 heroku[web.1]: State changed from starting to crashed
2018-05-10T22:07:01.651642+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=studentsrm.herokuapp.com request_id=03c47479-0408-4f2e-80de-e2cea63cfb2f fwd="155.98.26.248" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T22:07:02.342902+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=studentsrm.herokuapp.com request_id=b67cd2d5-9d5e-4ebd-8860-5d154d8905b9 fwd="155.98.26.248" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T22:07:02.792147+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=studentsrm.herokuapp.com request_id=7fdbdae1-dee3-41d6-b5cd-29d69363a6ba fwd="155.98.26.248" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T22:42:56.282822+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=studentsrm.herokuapp.com request_id=ff108727-d32a-4e56-a73a-9108eba66770 fwd="128.110.67.141" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T22:42:56.710680+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=studentsrm.herokuapp.com request_id=8d089bb4-9eda-4ef3-a4bc-d50ce6d10fc8 fwd="128.110.67.141" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T22:42:57.270927+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=studentsrm.herokuapp.com request_id=777a607f-e124-4c3b-a5a3-0fe66c702ad3 fwd="128.110.67.141" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T22:49:14.000000+00:00 app[api]: Build started by user alecdown@gmail.com
2018-05-10T22:49:27.099735+00:00 heroku[web.1]: State changed from crashed to starting
2018-05-10T22:49:26.807919+00:00 app[api]: Deploy a090bedb by user alecdown@gmail.com
2018-05-10T22:49:14.000000+00:00 app[api]: Build succeeded
2018-05-10T22:49:26.807919+00:00 app[api]: Release v8 created by user alecdown@gmail.com
2018-05-10T22:49:32.712799+00:00 heroku[web.1]: Starting process with command `gunicorn --bind 0.0.0.0:58513 app:app`
2018-05-10T22:49:35.252130+00:00 heroku[web.1]: State changed from starting to crashed
2018-05-10T22:49:35.254524+00:00 heroku[web.1]: State changed from crashed to starting
2018-05-10T22:49:35.211745+00:00 heroku[web.1]: Process exited with status 127
2018-05-10T22:49:35.126880+00:00 app[web.1]: bash: gunicorn: command not found
2018-05-10T22:49:38.790250+00:00 heroku[web.1]: Starting process with command `gunicorn --bind 0.0.0.0:57125 app:app`
2018-05-10T22:49:40.816894+00:00 heroku[web.1]: State changed from starting to crashed
2018-05-10T22:49:40.717556+00:00 app[web.1]: bash: gunicorn: command not found
2018-05-10T22:49:40.801628+00:00 heroku[web.1]: Process exited with status 127
2018-05-10T22:49:54.398172+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=studentsrm.herokuapp.com request_id=e6d1dbca-d8ae-4000-ae9b-45eec22d34ce fwd="128.110.67.141" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T22:49:54.798379+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=studentsrm.herokuapp.com request_id=736ee6c5-39e0-4458-91f8-cab97ed41562 fwd="128.110.67.141" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T22:49:55.332567+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=studentsrm.herokuapp.com request_id=1ae2a230-df67-4499-ac94-f84d13c27a2b fwd="128.110.67.141" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T22:56:40.000000+00:00 app[api]: Build started by user alecdown@gmail.com
2018-05-10T22:57:26.773375+00:00 app[api]: Release v9 created by user alecdown@gmail.com
2018-05-10T22:57:26.773375+00:00 app[api]: Deploy 3e108bb0 by user alecdown@gmail.com
2018-05-10T22:57:27.233444+00:00 heroku[web.1]: State changed from crashed to starting
2018-05-10T22:56:40.000000+00:00 app[api]: Build succeeded
2018-05-10T22:57:31.050572+00:00 heroku[web.1]: Starting process with command `gunicorn --bind 0.0.0.0:55771 app:app`
2018-05-10T22:57:32.513271+00:00 app[web.1]: bash: gunicorn: command not found
2018-05-10T22:57:32.564353+00:00 heroku[web.1]: Process exited with status 127
2018-05-10T22:57:32.879885+00:00 heroku[web.1]: State changed from starting to crashed
2018-05-10T22:57:45.674727+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=studentsrm.herokuapp.com request_id=84aded73-3ef0-4d7c-b7f7-893f9ff6b0c8 fwd="128.110.67.141" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T22:57:46.093177+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=studentsrm.herokuapp.com request_id=7171a96d-862f-4bc2-b787-2d2f3150ff5c fwd="128.110.67.141" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T22:57:46.585876+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=studentsrm.herokuapp.com request_id=d5ae2aca-0064-4466-b079-662d658d4fa0 fwd="128.110.67.141" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T23:00:51.828849+00:00 heroku[web.1]: State changed from crashed to starting
2018-05-10T23:00:57.099099+00:00 heroku[web.1]: Starting process with command `gunicorn --bind 0.0.0.0:27152 app:app`
2018-05-10T23:00:59.400276+00:00 heroku[web.1]: Process exited with status 127
2018-05-10T23:00:59.297280+00:00 app[web.1]: bash: gunicorn: command not found
2018-05-10T23:01:01.333027+00:00 heroku[web.1]: State changed from starting to crashed
2018-05-10T23:01:27.016797+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=studentsrm.herokuapp.com request_id=bf75b42b-da4a-49f6-b6c4-0065c0936143 fwd="128.110.67.141" dyno= connect= service= status=503 bytes= protocol=https
2018-05-10T23:01:27.265794+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=studentsrm.herokuapp.com request_id=2086a1d4-1369-483b-bbc6-fb659b56beb8 fwd="128.110.67.141" dyno= connect= service= status=503 bytes= protocol=https

You can define your Python environment on Heroku in one of two ways:

  1. With pip .

    You can include a requirements.txt file to list your requirements, and optionally use a runtime.txt file to specify a required Python version. In this case, Heroku will use pip to install your requirements :

    Heroku's pip support is very transparent. Any requirements that install locally with the following command will behave as expected on Heroku:

     pip install -r requirements.txt 
  2. With pipenv .

    Alternatively, you can specify your requirements in a Pipfile and Pipfile.lock . This option lets you set your required Python version right in your Pipfile . In this case, your dependencies will be installed using pipenv .

You are currently using a mixture of both, and the pipenv workflow will take precedence over the pip workflow. If all three files are present, requirements.txt , Pipfile , and Pipfile.lock , your requirements.txt will be ignored.

There are two solutions:

  1. Fully use pip .

    Delete your Pipfile and Pipfile.lock and add a runtime.txt file containing

     python-2.7.15 
  2. Fully use pipenv .

    Migrate your requirements from requirements.txt to Pipfile , run pipenv lock , letting pipenv see the dependencies, and remove requirements.txt .

    In this case you'll probably want to read the documentation for pipenv .

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