【问题标题】:Gunicorn 'Application Object Must Be Callable' errorGunicorn“应用程序对象必须是可调用的”错误
【发布时间】:2019-09-27 12:48:58
【问题描述】:

我正在尝试使用 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 调用的各种变体(例如在项目文件夹中并说 gunicornunified:app, being the parent folder and usinggunicorn folder:app,gunicorn folder:unified`。我知道它可以工作,因为它以前工作过。但就我的一生而言,我无法弄清楚现在发生了什么。

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

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

【问题讨论】:

    标签: python gunicorn hyphen


    【解决方案1】:

    gunicorn unified:app.server

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

    【讨论】:

    • 这个答案已经根据 gunicorn 的更新而改变。在较新版本的 gunicorn 上,正确的语法是 gunicorn unified:server。这是基于相同的链接。
    猜你喜欢
    • 2019-04-14
    • 1970-01-01
    • 2019-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多