无法加载应用0(mountpoint ='uwsgi')(未找到可调用或导入错误)

时间:2017-02-27 08:26:59

标签: python uwsgi ini

我正在尝试让uwsgi与python一起工作,但无论如何我无法加载我的应用程序..我收到此错误:

unable to load app 0 (mountpoint='uwsgi') (callable not found or import error)

uwsgi.ini:

[uwsgi]
http = 0.0.0.0:8000
module = uwsgi
callable = application

uwsgi.py:

def application(env, start_response):
start_response('200 OK', [('Content-Type', 'text/html')])
return ["Hello!"]

目录结构是这样的:

/config/
.... __init__.py
.... uwsgi.ini
.... uwsgi.py

我无法弄清楚出了什么问题。我已经通过这个网站上的几个例子,文章和答案,没有什么能解决我的问题..我已经尝试过命令行初始化并调用.ini,我不知道该怎么做,uwsgi似乎找到了uwsgi.py因为我没有收到模块未找到错误,但由于某种原因它无法加载。剥离命令行init是这个命令:

uwsgi --ini uwsgi.ini

但我尝试了几种变体,但显然没有一种变化。

这是完整的错误:

[uWSGI] getting INI configuration from /config/uwsgi.ini
*** Starting uWSGI 2.0.14 (64bit) on [Mon Feb 27 08:40:38 2017] ***
compiled with version: 4.9.2 on 26 February 2017 23:44:57
os: Linux-4.4.0-64-generic #85-Ubuntu SMP Mon Feb 20 11:50:30 UTC 2017
nodename: fe627d90246e
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /config
detected binary path: /usr/local/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
*** WARNING: you are running uWSGI without its master process manager ***
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on 0.0.0.0:8000 fd 4
spawned uWSGI http 1 (pid: 7)
uwsgi socket 0 bound to TCP address 127.0.0.1:36530 (port auto-assigned) fd 3
Python version: 3.6.0 (default, Feb 26 2017, 23:43:20)  [GCC 4.9.2]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x1df12c0
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72768 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
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 (and the only) (pid: 1, cores: 1)

2 个答案:

答案 0 :(得分:2)

检查文件的所有权。 uwsgi将与非特权用户一起运行。 确保www-data或您使用的任何用户对wsgi.py

具有读取权限

答案 1 :(得分:0)

这是适用于我的配置,wsgi.py:

def application(env, start_response):
    start_response('200 OK', [('Content-Type', 'text/html')])
    return ["Hello!"]

和uwsgi.ini:

[uwsgi]
http = 0.0.0.0:8000
module = wsgi
callable = application

然后像这样开始:

uwsgi --ini uwsgi.ini