Black Lives Matter. Please consider donating to Black Girls Code today.

Error when deploying Dash app on AWS ElasticBeanstalk

When I want to deploy a simple Dash app on AWS Elasticbeanstalk, this error occur:

TypeError: 'Dash' object is not callable
mod_wsgi (pid=5180): Exception occurred processing WSGI script '/opt/python/current/app/application.py'

I have tried:

application = dash.Dash(__name__)
server = application.server

as told in this issue

But the error still exist, I’m wondering where can I fix this problem, perhaps by changing wsgi setting?
Any suggestion is much appreciated, thanks in advance!

P.S.
the application notation in application.py is the common term for deploying flask apps on Elasticbeanstalk

application should point to the callable that is the entry point for a WSGI application. For Dash apps, this is the Flask instance that it uses, not the Dash app itself. You want something like this:

app = dash.Dash(__name__)
application = app.server
1 Like

nedned, Thanks for the detailed explanation!
Now the application is working like a charm on Elasticbeanstalk.
For other’s reference, the working app look like:

import dash
app = dash.Dash(__name__)
application = app.server

...

app.layout = html.Div([ ....

...

if __name__ == '__main__':
    application.run(debug=True)

Thanks again!

3 Likes