问题描述
该应用程序可以在本地计算机上完美运行,但是在部署到Heroku后,尝试在浏览器中打开该应用程序时出现了一个应用程序错误.检查了日志文件,并自己解决了一些小问题,但现在不能走了.部署前我已经完成的工作:
The application runs perfectly on the local computer, but after deployment to the Heroku, I am getting an application error when I try to open the application in my browser. Checked the log file and solved some minor problems myself, but I can not go further now. What I have done before deployment:
- pip安装gunicorn
- 点冻结> requirements.txt
- 创建了procfile,并在其中写了Web:gunicorn app:app
- heroku登录
- git init
- heroku git:remote-我的应用程序
- git add.
- git commit -am"1"
- git push heroku master
2020-10-30T21:02:37.970885+00:00 app[web.1]: worker.init_process()
2020-10-30T21:02:37.970885+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 119, in init_process
2020-10-30T21:02:37.970886+00:00 app[web.1]: self.load_wsgi()
2020-10-30T21:02:37.970886+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
2020-10-30T21:02:37.970886+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2020-10-30T21:02:37.970888+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2020-10-30T21:02:37.970888+00:00 app[web.1]: self.callable = self.load()
2020-10-30T21:02:37.970888+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
2020-10-30T21:02:37.970888+00:00 app[web.1]: return self.load_wsgiapp()
2020-10-30T21:02:37.970889+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
2020-10-30T21:02:37.970889+00:00 app[web.1]: return util.import_app(self.app_uri)
2020-10-30T21:02:37.970890+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 358, in import_app
2020-10-30T21:02:37.970890+00:00 app[web.1]: mod = importlib.import_module(module)
2020-10-30T21:02:37.970890+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
2020-10-30T21:02:37.970891+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2020-10-30T21:02:37.970892+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 994, in _gcd_import
2020-10-30T21:02:37.970892+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 971, in _find_and_load
2020-10-30T21:02:37.970892+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
2020-10-30T21:02:37.970893+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
2020-10-30T21:02:37.970893+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 678, in exec_module
2020-10-30T21:02:37.970893+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2020-10-30T21:02:37.970894+00:00 app[web.1]: File "/app/app.py", line 2, in <module>
2020-10-30T21:02:37.970894+00:00 app[web.1]: from main import views
2020-10-30T21:02:37.970894+00:00 app[web.1]: File "/app/main/views.py", line 5, in <module>
2020-10-30T21:02:37.970895+00:00 app[web.1]: from main.utils import pipeline_model
2020-10-30T21:02:37.970895+00:00 app[web.1]: File "/app/main/utils.py", line 6, in <module>
2020-10-30T21:02:37.970896+00:00 app[web.1]: import cv2
2020-10-30T21:02:37.970897+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/cv2/__init__.py", line 5, in <module>
2020-10-30T21:02:37.970897+00:00 app[web.1]: from .cv2 import *
2020-10-30T21:02:37.970905+00:00 app[web.1]: ImportError: libGL.so.1: cannot open shared object file: No such file or directory
2020-10-30T21:02:37.973156+00:00 app[web.1]: [2020-10-30 21:02:37 +0000] [10] [INFO] Worker exiting (pid: 10)
2020-10-30T21:02:38.493246+00:00 app[web.1]: [2020-10-30 21:02:38 +0000] [11] [ERROR] Exception in worker process
2020-10-30T21:02:38.493257+00:00 app[web.1]: Traceback (most recent call last):
2020-10-30T21:02:38.493259+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2020-10-30T21:02:38.493259+00:00 app[web.1]: worker.init_process()
2020-10-30T21:02:38.493260+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 119, in init_process
2020-10-30T21:02:38.493260+00:00 app[web.1]: self.load_wsgi()
2020-10-30T21:02:38.493261+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
2020-10-30T21:02:38.493261+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2020-10-30T21:02:38.493262+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2020-10-30T21:02:38.493262+00:00 app[web.1]: self.callable = self.load()
2020-10-30T21:02:38.493263+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
2020-10-30T21:02:38.493263+00:00 app[web.1]: return self.load_wsgiapp()
2020-10-30T21:02:38.493263+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
2020-10-30T21:02:38.493264+00:00 app[web.1]: return util.import_app(self.app_uri)
2020-10-30T21:02:38.493264+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 358, in import_app
2020-10-30T21:02:38.493264+00:00 app[web.1]: mod = importlib.import_module(module)
2020-10-30T21:02:38.493265+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
2020-10-30T21:02:38.493265+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2020-10-30T21:02:38.493266+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 994, in _gcd_import
2020-10-30T21:02:38.493267+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 971, in _find_and_load
2020-10-30T21:02:38.493267+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
2020-10-30T21:02:38.493267+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
2020-10-30T21:02:38.493268+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 678, in exec_module
2020-10-30T21:02:38.493268+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2020-10-30T21:02:38.493269+00:00 app[web.1]: File "/app/app.py", line 2, in <module>
2020-10-30T21:02:38.493269+00:00 app[web.1]: from main import views
2020-10-30T21:02:38.493269+00:00 app[web.1]: File "/app/main/views.py", line 5, in <module>
2020-10-30T21:02:38.493270+00:00 app[web.1]: from main.utils import pipeline_model
2020-10-30T21:02:38.493270+00:00 app[web.1]: File "/app/main/utils.py", line 6, in <module>
2020-10-30T21:02:38.493271+00:00 app[web.1]: import cv2
2020-10-30T21:02:38.493271+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/cv2/__init__.py", line 5, in <module>
2020-10-30T21:02:38.493272+00:00 app[web.1]: from .cv2 import *
2020-10-30T21:02:38.493280+00:00 app[web.1]: ImportError: libGL.so.1: cannot open shared object file: No such file or directory
2020-10-30T21:02:38.494646+00:00 app[web.1]: [2020-10-30 21:02:38 +0000] [11] [INFO] Worker exiting (pid: 11)
2020-10-30T21:02:38.670078+00:00 app[web.1]: Traceback (most recent call last):
2020-10-30T21:02:38.670085+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 209, in run
2020-10-30T21:02:38.670559+00:00 app[web.1]: self.sleep()
2020-10-30T21:02:38.670617+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 357, in sleep
2020-10-30T21:02:38.671121+00:00 app[web.1]: ready = select.select([self.PIPE[0]], [], [], 1.0)
2020-10-30T21:02:38.671176+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
2020-10-30T21:02:38.671571+00:00 app[web.1]: self.reap_workers()
2020-10-30T21:02:38.671632+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2020-10-30T21:02:38.672179+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2020-10-30T21:02:38.672283+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2020-10-30T21:02:38.672324+00:00 app[web.1]:
2020-10-30T21:02:38.672325+00:00 app[web.1]: During handling of the above exception, another exception occurred:
2020-10-30T21:02:38.672325+00:00 app[web.1]:
2020-10-30T21:02:38.672407+00:00 app[web.1]: Traceback (most recent call last):
2020-10-30T21:02:38.672450+00:00 app[web.1]: File "/app/.heroku/python/bin/gunicorn", line 8, in <module>
2020-10-30T21:02:38.672772+00:00 app[web.1]: sys.exit(run())
2020-10-30T21:02:38.672828+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 58, in run
2020-10-30T21:02:38.673110+00:00 app[web.1]: WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2020-10-30T21:02:38.673183+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 228, in run
2020-10-30T21:02:38.673593+00:00 app[web.1]: super().run()
2020-10-30T21:02:38.673651+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 72, in run
2020-10-30T21:02:38.673950+00:00 app[web.1]: Arbiter(self).run()
2020-10-30T21:02:38.674006+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 229, in run
2020-10-30T21:02:38.674395+00:00 app[web.1]: self.halt(reason=inst.reason, exit_status=inst.exit_status)
2020-10-30T21:02:38.674451+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 342, in halt
2020-10-30T21:02:38.674927+00:00 app[web.1]: self.stop()
2020-10-30T21:02:38.674986+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 393, in stop
2020-10-30T21:02:38.675477+00:00 app[web.1]: time.sleep(0.1)
2020-10-30T21:02:38.675534+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
2020-10-30T21:02:38.675933+00:00 app[web.1]: self.reap_workers()
2020-10-30T21:02:38.675990+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2020-10-30T21:02:38.676549+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2020-10-30T21:02:38.676613+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2020-10-30T21:02:38.760092+00:00 heroku[web.1]: Process exited with status 1
2020-10-30T21:02:38.805325+00:00 heroku[web.1]: State changed from up to crashed
2020-10-30T21:03:14.847423+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=face-1907.herokuapp.com request_id=9cc9542b-0ea0-481c-b2bd-29b1cc407769 fwd="88.252.193.107" dyno= connect= service= status=503 bytes= protocol=https
推荐答案
似乎缺少cv2
模块.您可以利用 heroku-buildpack-apt .
It seems like the cv2
module is missing. You can install these missing libraries taking advantage of the heroku-buildpack-apt.
在撰写本文时,我已经成功完成了为此回购,托管了此处,并执行以下步骤:
At the time of this writing, I have successfully done it for this repo, hosted here, with the following steps:
- 将heroku-buildpack-apt添加到Heroku平台上的构建包中
- 创建一个名为Aptfile的文件,并添加以下库:libsm6,libxrender1,libfontconfig1,libice6(每行一个).示例此处.
这篇关于使用Flask在Heroku上部署模型后,如何解决应用程序错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!