首页 > 解决方案 > Gunicorn“应用程序对象必须是可调用的”错误

问题描述

我正在尝试使用 gunicorn 和 nginx 部署一个用 Dash 编写的应用程序。几个月前,当我知道自己在做什么时,我成功地部署了同样的应用程序。我想进行一些更新并重新部署,但现在部署将无法正常工作,即使我摆脱了所有更新。当我运行 gunicorn 时,出现错误,Application must be callable.

我有我的项目folder,其中包含unified.py文件,其中有我的应用程序。在unified.pyapp = dash.Dash(__name__, external_stylesheets=external_stylesheets)所以我将我的 app 变量定义为 app.

我运行gunicorn folder.unified:app并收到此错误。但是,如果我运行,from folder.unified import app我会得到应用程序对象和所有正确的属性,没问题。

我已经尝试了 gunicorn 调用的各种变体(例如在项目文件夹中并说gunicorn统一:app , being the parent folder and usinggunicorn 文件夹:app ,gunicorn 文件夹:unified`。我知道它可以工作,因为它以前可以工作。但对于生活对我来说,我无法弄清楚现在发生了什么。

我希望它的运行与使用 python 运行应用程序时类似python unified.py

有一段时间我以为我解决了它,因为我开始收到一个不同的错误(说我无法从另一个文件夹中获取 .pkl 文件),但后来我在unified.py文件中注释掉了这些行,它又回到了相同的状态Application must be callable错误!

标签: pythongunicornhyphen

解决方案


gunicorn unified:app.server

来自我找到解决方案的 Plotly 论坛的交叉引用: https ://community.plot.ly/t/error-with-gunicorn/8247


推荐阅读