Flask and uWSGI - unable to load app 0 (mountpoint='') (callable not found or import error) Flask and uWSGI - unable to load app 0 (mountpoint='') (callable not found or import error) flask flask

Flask and uWSGI - unable to load app 0 (mountpoint='') (callable not found or import error)


I had problems with the accepted solution because my flask app was in a variable called app. You can solve that with putting just this in your wsgi:

from module_with_your_flask_app import app as application

So the problem was simply that uwsgi expects a variable called application.


uWSGI doesn't load your app as __main__, so it never will find the app (since that only gets loaded when the app is run as name __main__). Thus, you need to import it outside of the if __name__ == "__main__": block.

Really simple change:

from app import app as application  # for example, should be appif __name__ == "__main__":    application.run()

Now you can run the app directly with python run.py or run it through uWSGI the way you have it.

NOTE: if you set --callable myapp, you'd need to change it from as application to myapp (by default uwsgi expects application


The uWSGI error unable to load app 0 (mountpoint='') (callable not found or import error) occured for me if I left out the last two lines of the following minimal working example for Flask application

from flask import Flaskapp = Flask(__name__)@app.route("/")def hello():    return "Hello world!"if __name__ == "__main__":    app.run()else:    application = app

I am aware that this already implicitly said within the comments to another answer, but it still took me a while to figure that out, so I hope to save others' time.

In the case of a pure Python Dash application, I can offer the following minimal viable code snippet:

import dashimport dash_core_components as dccimport dash_html_components as htmlapp = dash.Dash()app.layout = html.Div( html.H1(children="Hello World") )application = app.serverif __name__ == "__main__":    app.run_server(debug=True)

Again, the application = app.server is the essential part here.