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

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

import os
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.login import LoginManager
#from flaskext.babel import Babel
from config import basedir
app = 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 in to access this page."

from app import views

*** Operational MODE: preforking ***
unable to find "application" callable in file /path/to/folder/run.py
unable to load app 0 (mountpoint=‘‘) (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (pid: 26972, cores: 1)
spawned uWSGI worker 2 (pid: 26973, cores: 1)

python flask uwsgi


shareimprove this question

edited Dec 17 ‘13 at 18:02

akira

4,6621828

asked Aug 19 ‘12 at 23:30

Tampa

9,16940126209

 
add a comment

2 Answers

activeoldestvotes


up vote13down voteaccepted

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

if __name__ == "__main__":
    app.run()

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

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

时间: 2024-08-09 08:37:56

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

uwsgi启动Django项目时:unable to load app 0 (mountpoint='') (callable not found or import error) *** no app loaded. going in full dynamic mode ***

说起来有点坑 用命令都能正常启动,但是用配置文件就是不行 提示 unable to load app 0 (mountpoint='') (callable not found or import error) *** no app loaded. going in full dynamic mode *** 最后准备睡觉了了,无意间解决了 uwsgi.ini文件的wsgi模块是这样写的,一直报错,网上的都找遍了还是没解决 module = AutoTestSite.wsgi:applicati

Hadoop 2.2.0 常见问题之:Ubuntu 64环境下“Unable to load native-hadoop library for your platform”问题”

问题 最近在学习Hadoop(2.2.0),打算写一个MapReduce的小程序在Ubuntu 64位的环境下测试一把,一切环境配置完毕后,执行的过程中,控制台输出下面的内容: WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable 原因 在网上搜索了一番,得出如下结论: "The reason

hadoop2.6.0实践:A02 问题处理 util.NativeCodeLoader: Unable to load native-hadoop library for your platform

############################################################# hadoop "util.NativeCodeLoader: Unable to load native-hadoop library for your platform" hadoop安装完以后,经常会提示以下警告: WARN util.NativeCodeLoader: Unable to load native-hadoop library for your

jenkins 启动slave,出现com.sun.deploy.net.FailedDownloadException: Unable to load resource: http://127.0.0.1:8080/jnlpJars/remoting.jar

master: linux slave: win7 64位系统 在配置好系统后,采用jnlp的方式启动slave节点,报错如下: com.sun.deploy.net.FailedDownloadException: Unable to load resource: http://127.0.0.1:8080/jnlpJars/remoting.jar at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source) at c

Unable to load configuration. - action - file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%209.0/webapps/Teacher04/WEB-INF/classes/struts.xml:9:54

发布一个struts2项目的时候tomcat显示下面这个错误,我的本能感觉就是我的struts.xml或者web.xml写错了,可是我字母找都没发现,于是百度一番,可是我对那些人的回答表示怀疑,感觉应该不行,直到我一直找下去,发现一个不起眼的回答说出了我需要的回答 我回来一看,发现我的错误里的确有这个struts.xml:9:54,于是看一下我的struts.xml,我要哭了 严重: Exception starting filter struts2 Unable to load configu

版本问题 Java:Unsupported major.minor version 51.0 (unable to load class . . .

导入别人的项目时报错  Java:Unsupported major.minor version 51.0 (unable to load class . . . 后发现错误是由于class编译器的JDK版本高于运行期的JDK版本. 比如我在运行Tomcat servlet时出现该错误,是由于tomcat运行时是1.6的JDK,Eclipse编译时则是1.7 于是: 一.查看jdk版本 在运行里点cmd,然后点java -version就能看到JDK版本了. 二.查看tomcat版本 Tomca

关于cocos2dx 3.0升级崩溃报错(unable to load native library) 和(Fatal signal 11 (SIGSEGV) at 0x00000000)

最近一直在Windows平台开发cocos-2dx游戏,期间做了一次引擎升级,升级到了3.0正式版本.Windows平台上表现很正常,没有出现什么问题. 上周五准备发布一个安卓包,编译很轻松的就过了,没有花费多少时间,但是安装到手机后,发现运行就崩溃了.没办法只好用模拟机调试,再次吐槽Android的模拟器,真的太他妈慢了,不到万不得已我真的不想再去用它,google真的应该好好整一下了. 好不容易运行起来了,看到崩溃的时候logcat的报错是"unable to load native lib

Caused by: Unable to load configuration. - action - file:/C:/apache-tomcat-7.0.70/webapps/Structs/WEB-INF/classes/struts.xml:7:72 at com.opensymphony.xwork2.config.ConfigurationManager.getConfigurati

Unable to load configuration. - action - file:/C:/apache-tomcat-7.0.70/webapps/Structs/WEB-INF/classes/struts.xml:7:72 at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:431) at org.apache.struts2.dispatcher.ng.InitOperations.initDispat

Tomcat - java.lang.UnsupportedClassVersionError:Unsupported major.minor version 51.0 (unable to load class com.microsoft.sqlserver.jdbc.SQLS

今天使用Tomcat连接sql Server 2008 enterprise的时候,报错: HTTP Status 500 - Servlet execution threw an exception type Exception report message Servlet execution threw an exception description The server encountered an internal error that prevented it from fulfil