在heroku上部署python服务器时出现应用程序错误

时间:2021-07-19 12:57:13

标签: python html git github heroku

这是我关于堆栈溢出的第一个问题,抱歉我的英语不好。 最近我正在尝试编写一个网站,但遇到了一些问题。 我试图部署我的 python 服务器(使用烧瓶)。 Github shows that my deployment is active.

But this error came in like a wrecking ball

heroku 在 cmd 中记录 --tail:

2021-07-20T13:39:36.000000+00:00 app[api]: Build started by user s0975247623@gmail.com
2021-07-20T13:40:05.927874+00:00 app[api]: Deploy eab08b00 by user s0975247623@gmail.com
2021-07-20T13:40:05.927874+00:00 app[api]: Release v7 created by user s0975247623@gmail.com
2021-07-20T13:40:15.000000+00:00 app[api]: Build succeeded
2021-07-20T13:40:41.620229+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=weberchangwebsite.herokuapp.com request_id=eb99ce18-a05a-467d-83e3-677750566005 fwd="42.77.102.103" dyno= connect= service= status=503 bytes= protocol=https
2021-07-20T13:40:42.346007+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=weberchangwebsite.herokuapp.com request_id=f4cb288e-57d0-439c-8045-e6657d982d74 fwd="42.77.102.103" dyno= connect= service= status=503 bytes= protocol=https
2021-07-20T13:42:54.130237+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=weberchangwebsite.herokuapp.com request_id=ba3cee47-4c60-4da3-b462-fc7fc603c113 fwd="42.77.102.103" dyno= connect= service= status=503 bytes= protocol=https
2021-07-20T13:42:54.490527+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=weberchangwebsite.herokuapp.com request_id=bb279054-b1d0-4338-a151-9c0d182f0e60 fwd="42.77.102.103" dyno= connect= service= status=503 bytes= protocol=https
2021-07-20T13:47:00.708973+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=weberchangwebsite.herokuapp.com request_id=e9cdfbb7-c496-4fcc-83ce-281e38aac026 fwd="42.77.102.103" dyno= connect= service= status=503 bytes= protocol=https
2021-07-20T13:47:01.118554+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=weberchangwebsite.herokuapp.com request_id=61256046-a30d-47dd-82b2-c6b46c0dddeb fwd="42.77.102.103" dyno= connect= service= status=503 bytes= protocol=https
2021-07-20T14:04:55.170085+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=weberchangwebsite.herokuapp.com request_id=1547a37e-2adc-4821-a44f-946b8640aea7 fwd="42.77.102.103" dyno= connect= service= status=503 bytes= protocol=https
2021-07-20T14:04:55.565447+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=weberchangwebsite.herokuapp.com request_id=987287ad-fb93-4af6-be8a-c2205acf9eee fwd="42.77.102.103" dyno= connect= service= status=503 bytes= protocol=https

在heroku上构建日志

-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/python
-----> Python app detected
-----> No Python version was specified. Using the same version as the last build: python-3.9.6
   To use a different version, see: https://devcenter.heroku.com/articles/python-runtimes
-----> Requirements file has been changed, clearing cached dependencies
cp: cannot stat '/tmp/build_ab78a77f/requirements.txt': No such file or directory
-----> Installing python-3.9.6
-----> Installing pip 20.2.4, setuptools 47.1.1 and wheel 0.36.2
-----> Installing SQLite3
-----> Installing requirements with pip
   Obtaining file:///tmp/build_ab78a77f (from -r /tmp/build_ab78a77f/requirements.txt (line 1))
   ERROR: No .egg-info directory found in /tmp/pip-pip-egg-info-ahj6gkzs
 !     Push rejected, failed to compile Python app.
 !     Push failed

我的python服务器:

from flask import Flask
from flask import render_template
from flask import url_for
app=Flask(__name__)
@app.route("/")
def hello():
    return render_template("richardo.html")
@app.route("/About_me")
def hello2():
    return render_template("About_me.html")
@app.route("/My_GitHub")
def hello3():
    return render_template("MyGitHub.html")
if __name__=="__main__":
    app.debug=True
app.run()

我的需求.txt:

Click==7.0
Flask==2.0.1
gunicorn==20.1.0
itsdangerous==1.1.0
Jinja2==2.10.1
MarkupSafe==1.1.1
Werkzeug==0.15.6

gunicorn 是我问题的解决方案吗?
或者我需要别的东西吗?

[2021/7/24 更新]
添加Procfile后,H14错误消失了。但是现在出现了 H10 错误。
过程:

web: gunicorn server:app

日志:

2021-07-26T09:33:36.784909+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/util.py", line 359, in import_app
2021-07-26T09:33:36.784909+00:00 app[web.1]: mod = importlib.import_module(module)
2021-07-26T09:33:36.784909+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/importlib/__init__.py", line 127, in import_module
2021-07-26T09:33:36.784910+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2021-07-26T09:33:36.784910+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
2021-07-26T09:33:36.784911+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
2021-07-26T09:33:36.784911+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
2021-07-26T09:33:36.784911+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
2021-07-26T09:33:36.784912+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 850, in exec_module
2021-07-26T09:33:36.784912+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
2021-07-26T09:33:36.784913+00:00 app[web.1]: File "/app/server.py", line 1, in <module>
2021-07-26T09:33:36.784913+00:00 app[web.1]: from flask import Flask
2021-07-26T09:33:36.784914+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/flask/__init__.py", line 7, in <module>
2021-07-26T09:33:36.784914+00:00 app[web.1]: from .app import Flask as Flask
2021-07-26T09:33:36.784925+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/flask/app.py", line 19, in <module>
2021-07-26T09:33:36.784926+00:00 app[web.1]: from werkzeug.local import ContextVar
2021-07-26T09:33:36.784927+00:00 app[web.1]: ImportError: cannot import name 'ContextVar' from 'werkzeug.local' (/app/.heroku/python/lib/python3.9/site-packages/werkzeug/local.py)
2021-07-26T09:33:36.785162+00:00 app[web.1]: [2021-07-26 09:33:36 +0000] [8] [INFO] Worker exiting (pid: 8)
2021-07-26T09:33:36.817056+00:00 app[web.1]: [2021-07-26 09:33:36 +0000] [4] [WARNING] Worker with pid 8 was terminated due to signal 15
2021-07-26T09:33:36.913989+00:00 app[web.1]: [2021-07-26 09:33:36 +0000] [4] [INFO] Shutting down: Master
2021-07-26T09:33:36.914119+00:00 app[web.1]: [2021-07-26 09:33:36 +0000] [4] [INFO] Reason: Worker failed to boot.
2021-07-26T09:33:36.983200+00:00 heroku[web.1]: Process exited with status 3
2021-07-26T09:33:37.056364+00:00 heroku[web.1]: State changed from starting to crashed
2021-07-26T10:42:29.153653+00:00 heroku[web.1]: State changed from crashed to starting
2021-07-26T10:42:33.604500+00:00 heroku[web.1]: Starting process with command `gunicorn server:app`
2021-07-26T10:42:37.846784+00:00 app[web.1]: [2021-07-26 10:42:37 +0000] [4] [INFO] Starting gunicorn 20.1.0
2021-07-26T10:42:37.847744+00:00 app[web.1]: [2021-07-26 10:42:37 +0000] [4] [INFO] Listening at: http://0.0.0.0:50926 (4)
2021-07-26T10:42:37.848135+00:00 app[web.1]: [2021-07-26 10:42:37 +0000] [4] [INFO] Using worker: sync
2021-07-26T10:42:37.860968+00:00 app[web.1]: [2021-07-26 10:42:37 +0000] [7] [INFO] Booting worker with pid: 7
2021-07-26T10:42:37.954786+00:00 app[web.1]: [2021-07-26 10:42:37 +0000] [8] [INFO] Booting worker with pid: 8
2021-07-26T10:42:38.431073+00:00 heroku[web.1]: State changed from starting to up
2021-07-26T10:42:39.260000+00:00 app[web.1]: [2021-07-26 10:42:39 +0000] [7] [ERROR] Exception in worker process
2021-07-26T10:42:39.260032+00:00 app[web.1]: Traceback (most recent call last):
2021-07-26T10:42:39.260034+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
2021-07-26T10:42:39.260035+00:00 app[web.1]: worker.init_process()
2021-07-26T10:42:39.260035+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 134, in init_process
2021-07-26T10:42:39.260035+00:00 app[web.1]: self.load_wsgi()
2021-07-26T10:42:39.260036+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
2021-07-26T10:42:39.260036+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2021-07-26T10:42:39.260037+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi
2021-07-26T10:42:39.260037+00:00 app[web.1]: self.callable = self.load()
2021-07-26T10:42:39.260038+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
2021-07-26T10:42:39.260038+00:00 app[web.1]: return self.load_wsgiapp()
2021-07-26T10:42:39.260038+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
2021-07-26T10:42:39.260039+00:00 app[web.1]: return util.import_app(self.app_uri)
2021-07-26T10:42:39.260039+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/util.py", line 359, in import_app
2021-07-26T10:42:39.260040+00:00 app[web.1]: mod = importlib.import_module(module)
2021-07-26T10:42:39.260040+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/importlib/__init__.py", line 127, in import_module
2021-07-26T10:42:39.260041+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2021-07-26T10:42:39.260041+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
2021-07-26T10:42:39.260042+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
2021-07-26T10:42:39.260042+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
2021-07-26T10:42:39.260043+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
2021-07-26T10:42:39.260043+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 850, in exec_module
2021-07-26T10:42:39.260043+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
2021-07-26T10:42:39.260044+00:00 app[web.1]: File "/app/server.py", line 1, in <module>
2021-07-26T10:42:39.260044+00:00 app[web.1]: from flask import Flask
2021-07-26T10:42:39.260044+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/flask/__init__.py", line 7, in <module>
2021-07-26T10:42:39.260045+00:00 app[web.1]: from .app import Flask as Flask
2021-07-26T10:42:39.260045+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/flask/app.py", line 19, in <module>
2021-07-26T10:42:39.260045+00:00 app[web.1]: from werkzeug.local import ContextVar
2021-07-26T10:42:39.260047+00:00 app[web.1]: ImportError: cannot import name 'ContextVar' from 'werkzeug.local' (/app/.heroku/python/lib/python3.9/site-packages/werkzeug/local.py)
2021-07-26T10:42:39.260235+00:00 app[web.1]: [2021-07-26 10:42:39 +0000] [7] [INFO] Worker exiting (pid: 7)
2021-07-26T10:42:39.291230+00:00 app[web.1]: [2021-07-26 10:42:39 +0000] [8] [ERROR] Exception in worker process
2021-07-26T10:42:39.291233+00:00 app[web.1]: Traceback (most recent call last):
2021-07-26T10:42:39.291234+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
2021-07-26T10:42:39.291235+00:00 app[web.1]: worker.init_process()
2021-07-26T10:42:39.291235+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 134, in init_process
2021-07-26T10:42:39.291236+00:00 app[web.1]: self.load_wsgi()
2021-07-26T10:42:39.291236+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
2021-07-26T10:42:39.291236+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2021-07-26T10:42:39.291237+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi
2021-07-26T10:42:39.291238+00:00 app[web.1]: self.callable = self.load()
2021-07-26T10:42:39.291238+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
2021-07-26T10:42:39.291239+00:00 app[web.1]: return self.load_wsgiapp()
2021-07-26T10:42:39.291239+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
2021-07-26T10:42:39.291240+00:00 app[web.1]: return util.import_app(self.app_uri)
2021-07-26T10:42:39.291240+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/util.py", line 359, in import_app
2021-07-26T10:42:39.291241+00:00 app[web.1]: mod = importlib.import_module(module)
2021-07-26T10:42:39.291241+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/importlib/__init__.py", line 127, in import_module
2021-07-26T10:42:39.291242+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2021-07-26T10:42:39.291242+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
2021-07-26T10:42:39.291243+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
2021-07-26T10:42:39.291243+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
2021-07-26T10:42:39.291244+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
2021-07-26T10:42:39.291244+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 850, in exec_module
2021-07-26T10:42:39.291245+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
2021-07-26T10:42:39.291245+00:00 app[web.1]: File "/app/server.py", line 1, in <module>
2021-07-26T10:42:39.291245+00:00 app[web.1]: from flask import Flask
2021-07-26T10:42:39.291246+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/flask/__init__.py", line 7, in <module>
2021-07-26T10:42:39.291246+00:00 app[web.1]: from .app import Flask as Flask
2021-07-26T10:42:39.291247+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/flask/app.py", line 19, in <module>
2021-07-26T10:42:39.291247+00:00 app[web.1]: from werkzeug.local import ContextVar
2021-07-26T10:42:39.291248+00:00 app[web.1]: ImportError: cannot import name 'ContextVar' from 'werkzeug.local' (/app/.heroku/python/lib/python3.9/site-packages/werkzeug/local.py)
2021-07-26T10:42:39.300032+00:00 app[web.1]: [2021-07-26 10:42:39 +0000] [8] [INFO] Worker exiting (pid: 8)
2021-07-26T10:42:39.352835+00:00 app[web.1]: [2021-07-26 10:42:39 +0000] [4] [WARNING] Worker with pid 8 was terminated due to signal 15
2021-07-26T10:42:39.440094+00:00 app[web.1]: [2021-07-26 10:42:39 +0000] [4] [INFO] Shutting down: Master
2021-07-26T10:42:39.440261+00:00 app[web.1]: [2021-07-26 10:42:39 +0000] [4] [INFO] Reason: Worker failed to boot.
2021-07-26T10:42:39.579930+00:00 heroku[web.1]: Process exited with status 3
2021-07-26T10:42:39.688437+00:00 heroku[web.1]: State changed from up to crashed
2021-07-26T11:17:22.185956+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=weberchangwebsite.herokuapp.com request_id=86c9212a-33b9-4521-9c6e-becc8ecce2a4 fwd="42.77.188.116" dyno= connect= service= status=503 bytes= protocol=https
2021-07-26T11:17:22.886735+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=weberchangwebsite.herokuapp.com request_id=16914fac-e519-4c0b-8430-2fc9e28d2588 fwd="42.77.188.116" dyno= connect= service= status=503 bytes= protocol=https

有谁知道我错过了什么?
[八月更新]
问题解决了~

0 个答案:

没有答案