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

Source: Internet
Author: User

Here is my directory structure:

-/path/to/folder/run.py -|app -|__init__.py -|views.py -|templates -|static

Contents of/path/to/folder/run.py

if __name__ == ‘__main__‘: from app import app #app.run(debug = True) app.run()

Contents of/path/to/folder/app/__init__.py

ImportOsFromFlaskImport FlaskFromFlask.Ext.SQLAlchemyImport SQLAlchemyFromFlask.Ext.LoginImport Loginmanager#from Flaskext.babel Import BabelFromConfigImportBasedirapp= Flask(__name__)App.Config.From_object(' Config ')#app. Config.from_pyfile (' babel.cfg ')Db= SQLAlchemy(App)Login_manager= Loginmanager()Login_manager.Setup_app(App)Login_manager.Login_view= ' Login 'Login_manager.Login_message=U"Please log on to access this page."FromAppImportViews*** OperationalMODE:Preforking***Unable to find"Application"CallableInchFile/Path/To/Folder/Run.Pyunable to load App0 (Mountpoint=‘‘) (CallableNotFoundOr ImportError)***No app Loaded.GoingInchFull dynamic mode****** Uwsgi is running in***spawned uwsgi worker 1  (pid: 26972< Span class= "pun" >, Cores: 1 spawned uwsgi worker 2  (pid: 26973 Cores: 1)    
Python flask Uwsgi
ShareImprove this question Edited Dec ' at 18:02Akira 4,662 Asked ' at 23:30Tampa9,169126 209
Add a Comment
2 Answersactiveoldestvotes
Up vote13down voteaccepted

Uwsgi doesn ' t load your app as  __main__ , so it never would find The app   (since, loaded when the app is run as name  __main__ ). Thus, need to import it outside of the  if __name__ = = "__main__":  block.

Really simple change:

  from app import Appif __name__ = =  "__main__" : App.< Span class= "PLN" >run ()                

Now you can run the app directly with  python run.py  or run it through Uwsgi the "the" I

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.