gpt4 book ai didi

python - uWSGI + Django + Python : no module named uwsgi

转载 作者:太空宇宙 更新时间:2023-11-03 13:39:01 27 4
gpt4 key购买 nike

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

./manage.py runserver 0.0.0.0:9010

但是当我尝试

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

我明白了

ImportError: No module named wsgi

我做错了什么?

这是完整的日志:

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)

最佳答案

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

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

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

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

我个人更喜欢第二种。

关于python - uWSGI + Django + Python : no module named uwsgi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34800514/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com