首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >uWSGI + Django + Python:没有名为uwsgi的模块

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

Stack Overflow用户
提问于 2016-01-14 21:55:08
回答 1查看 9.5K关注 0票数 5

我正试图为Django项目设置uwsgi。它运行良好

代码语言:javascript
复制
./manage.py runserver 0.0.0.0:9010

但当我尝试

代码语言:javascript
复制
 uwsgi --http :9010 --chdir /home/user/appname --module wsgi --wsgi-file /home/user/appname/appname/wsgi.py 

我得到了

代码语言:javascript
复制
ImportError: No module named wsgi

我做错什么了?

以下是完整的日志:

代码语言:javascript
复制
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)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-01-14 22:04:00

问题是您的应用程序没有一个名为uwsgi的模块。您将目录更改为/home/user/appname,但看起来实际的模块将是appname.uwsgi,因为uwsgi.py文件位于/home/user/appname/appname/uwsgi.py中。

通常情况下,您不需要同时指定--wsgi-file--module,所以我可以这样做

代码语言:javascript
复制
uwsgi --http :9010 --chdir /home/user/appname --wsgi-file /home/user/appname/appname/wsgi.py

代码语言:javascript
复制
uwsgi --http :9010 --chdir /home/user/appname --module appname.uwsgi

我个人更喜欢第二种。

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34800514

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档