简体   繁体   English

uWSGI + Django + Python:没有名为uwsgi的模块

[英]uWSGI + Django + Python: no module named uwsgi

I am trying to setup uwsgi for my Django project. 我正在尝试为我的Django项目设置uwsgi。 It runs fine with 它运行良好

./manage.py runserver 0.0.0.0:9010

But when I try 但是,当我尝试

 uwsgi --http :9010 --chdir /home/user/appname --module wsgi --wsgi-file /home/user/appname/appname/wsgi.py 

I get 我明白了

ImportError: No module named wsgi

What I am doing wrong ? 我做错了什么?

Here is the full log: 这是完整的日志:

uWSGI http bound on :9010 fd 4
spawned uWSGI http 1 (pid: 1900)
uwsgi socket 0 bound to TCP address 127.0.0.1:42684 (port auto-assigned) fd 3
Python version: 2.7.9 (default, Mar  1 2015, 13:01:26)  [GCC 4.9.2]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x1c17310
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72760 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
ImportError: No module named wsgi
unable to load app 0 (mountpoint='') (callable not found or import error)
Traceback (most recent call last):
  File "/home/robert/surmaroute/surmaroute/wsgi.py", line 13, in <module>
    from django.core.wsgi import get_wsgi_application
ImportError: No module named django.core.wsgi
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: 1899, cores: 1)

The issue is that your app does not have a module named uwsgi . 问题是您的应用程序没有名为uwsgi的模块。 You change the directory to /home/user/appname but it looks like the actual module would be appname.uwsgi since the uwsgi.py file lives within /home/user/appname/appname/uwsgi.py . 您将目录更改为/home/user/appname但实际模块看起来像是appname.uwsgi因为uwsgi.py文件位于/home/user/appname/appname/uwsgi.py

Typically though, you don't need to specify both --wsgi-file and --module so I would either do 通常,您不需要同时指定--wsgi-file--module所以我会这样做

uwsgi --http :9010 --chdir /home/user/appname --wsgi-file /home/user/appname/appname/wsgi.py

or 要么

uwsgi --http :9010 --chdir /home/user/appname --module appname.uwsgi

I personally prefer the second. 我个人更喜欢第二个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM