python - Gunicorn“应用程序对象必须是可调用的”错误
问题描述
我正在尝试使用 gunicorn 和 nginx 部署一个用 Dash 编写的应用程序。几个月前,当我知道自己在做什么时,我成功地部署了同样的应用程序。我想进行一些更新并重新部署,但现在部署将无法正常工作,即使我摆脱了所有更新。当我运行 gunicorn 时,出现错误,Application must be callable
.
我有我的项目folder
,其中包含unified.py
文件,其中有我的应用程序。在unified.py
,app = 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 using
gunicorn 文件夹:app ,
gunicorn 文件夹:unified`。我知道它可以工作,因为它以前可以工作。但对于生活对我来说,我无法弄清楚现在发生了什么。
我希望它的运行与使用 python 运行应用程序时类似python unified.py
。
有一段时间我以为我解决了它,因为我开始收到一个不同的错误(说我无法从另一个文件夹中获取 .pkl 文件),但后来我在unified.py
文件中注释掉了这些行,它又回到了相同的状态Application must be callable
错误!
解决方案
gunicorn unified:app.server
来自我找到解决方案的 Plotly 论坛的交叉引用: https ://community.plot.ly/t/error-with-gunicorn/8247
推荐阅读
- angular - Angular 7:使用查询参数刷新页面导致路径不匹配
- java - 为什么我的循环输出两个不同的结果?
- jquery - 如何使用 jquery 删除输入数据?
- javascript - 如何用变量替换 HTML 元素的所有实例(或更简单的方法)
- r - 从闪亮下载
- python-3.x - Python3:模块'x'没有属性'y'
- azure - 自定义 WebApi 技能不填充索引
- reactjs - 将动态复选框的值存储到状态挂钩中
- java - “WAP 一个查找 0 到 100 之间素数的程序”
- python - coverage.py 给出“没有代码源”,尽管 .coveragerc 似乎告诉它代码在哪里