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

时间:2022-03-04 22:49:54

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)
asked Aug 19 '12 at 23:30
Flask and uWSGI - unable to load app 0 (mountpoint='') (callable not found or import error)
Tampa
9,16940126209
 

2 Answers

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)的更多相关文章

  1. 关于ImportError: libssl.so.10: cannot open shared object file: No such file or directory unable to load app 0 (mountpoint='') (callable not found or import error)

    一.问题描述 在亚马逊云服务器使用Nginx+uwsgi部署django项目时,项目可以使用python manage.py runserver正常运行,uwsgi测试也没问题,Nginx也正常启动, ...

  2. 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 (mountpoint='') (callable not found or import err ...

  3. 报错:Unable to load configuration. - action - file:/E:/apache-tomcat-8.0.37/webapps/20161102-struts2-3/WEB-INF/classes/struts.xml:11:73

    第一种报错: 严重: Exception starting filter struts2Unable to load configuration. - action - file:/E:/apache ...

  4. 出现错误:Unable to load configuration. - action - file:/E:/Java/Tomcat7.0/apache-tomcat-7.0.68-windows-x64/apache-tomcat-7.0.68/webapps/SSH2Integrate/WEB-INF/classes/struts.xml:8:43

    严重: Exception starting filter struts2 Unable to load configuration. - action - file:/E:/Java/Tomcat7 ...

  5. 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 ...

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

    近期一直在Windows平台开发cocos-2dx游戏,期间做了一次引擎升级,升级到了3.0正式版本号.Windows平台上表现非常正常,没有出现什么问题. 上周五准备公布一个安卓包,编译非常轻松的就 ...

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

    导入别人的项目时报错  Java:Unsupported major.minor version 51.0 (unable to load class . . . 后发现错误是由于class编译器的J ...

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

    ############################################################# hadoop "util.NativeCodeLoader: Un ...

  9. Unable to load configuration. - action - file:/F:/apache-tomcat-8.0.30/webapps/test1Struts2/WEB-INF/classes/struts.xml:11:71

    Unable to load configuration. - action - file:/F:/apache-tomcat-8.0.30/webapps/test1Struts2/WEB-INF/ ...

随机推荐

  1. ACM交流赛感悟

    A题很水,字符串匹配,提交好几次都没通过,后来老何提醒后,发现题意理解错了,改过来之后,还是没过----------------在敲代码之前,一定要三个人统一一下思路,思路一样的话,开敲: F题是简单 ...

  2. codeforces 354 DIV2

    B - Pyramid of Glasses n层杯子,问k分钟能流满多少个杯子?和到香槟一样的过程? 思路:应为水的流速为每分钟一立方体(YY),可以做个转化,把最上层的杯子最原始的容积看成K,每个 ...

  3. Ubuntu初始化设置

    1.安装chrome sudo apt-get install chromium-browser sudo apt-get install pepperflashplugin-nonfree sudo ...

  4. 创建python虚拟环境如果速度很慢

    conda create -n jjenv python=3.6如果我们这样子创建的话下载速度很慢,那就可以用如下方式,相当于改了下载源. conda create -n jjenv python=3 ...

  5. 两分钟搞懂UiAutomator、UiAutomator2、Bootstrap的关系

    很多同学经过一段时间的学习之后都明白了Appium的基本原理,但是越学习到后面发现出现的很多陌生名词无法弄清楚其具体作用,今天这篇文章的目的就是为了让大家来弄懂三个高频名词:UiAutomator.U ...

  6. git修改文件夹名字

    git mv -f oldfolder newfolder git add -u newfolder (-u选项会更新已经追踪的文件和文件夹) git commit -m "changed ...

  7. centos关机与重启命令 shutdown -r now 立刻重启

    centos关机与重启命令详解与实战 Linux centos重启命令: .reboot .shutdown -r now 立刻重启(root用户使用) .shutdown -r 过10分钟自动重启( ...

  8. mysql 查询优化 ~explain解读之extra解读

    一 explain 常用状态 1 using filesort 常见于order by 字段 无法走索引造成,文件排序.需要注意优化,复杂条件可以选择建立联合索引进行优化2 using join bu ...

  9. python学习笔记_week14

    Web框架本质 众所周知,对于所有的Web应用,本质上其实就是一个socket服务端,用户的浏览器其实就是一个socket客户端. s1 import socket def handle_reques ...

  10. WinRAR 0day漏洞 附利用过程

    英国安全机构Mohammad Reza Espargham的漏洞实验室发现,流行压缩工具WinRAR 5.21最新版里存在一个安全漏洞,目前该漏洞还属于零日漏洞,同时官方正在全力修补该漏洞.同时报告该 ...