为啥我的 uWSGI 找不到我的 Django 应用程序?
Posted
技术标签:
【中文标题】为啥我的 uWSGI 找不到我的 Django 应用程序?【英文标题】:Why my uWSGI cannot find my Django application?为什么我的 uWSGI 找不到我的 Django 应用程序? 【发布时间】:2012-04-13 05:33:08 【问题描述】:我在这个论坛上遇到过很多类似的问题,但我的问题仍然困扰着我。
我的项目布局
/home/django/apps
|- movehere_env <--- Virtualenv. Everthing, including uwsgi is installed in it.
|- movehere_store
|- settings.py
|- apps
|- Other project stuff
|- prod <--- Stores settings for prod env
|- uwsgi.ini <--- uwsgi ini file
|- wsgi.py <--- Python code which has the Django application.
uwsgi.ini
[uwsgi]
socket = /tmp/movehere_store_uwsgi.sock
chdir = /home/django/apps
module = 'movehere_store.prod.wsgi:application'
master = True
pidfile = /tmp/movehere_store.pid
vacuum = True
max-requests = 5000
daemonize = /var/log/uwsgi/uwsgi.log
virtualenv = /home/django/apps/movehere_env
#harakiri = 20
processes = 5
pp = /home/django/apps
uwsgi.log
Python version: 2.6.5 (r265:79063, Jun 25 2011, 08:29:14) [GCC 4.4.4 20100726 (Red Hat 4.4.4-13)]
Set PythonHome to /home/django/apps/movehere_env
Python main interpreter initialized at 0x9922be0
your server socket listen backlog is limited to 100 connections
*** Operational MODE: preforking ***
added /home/django/apps/ to pythonpath.
ImportError: No module named 'movehere_store.prod.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 master process (pid: 15050)
spawned uWSGI worker 1 (pid: 15051, cores: 1)
spawned uWSGI worker 2 (pid: 15052, cores: 1)
spawned uWSGI worker 3 (pid: 15053, cores: 1)
spawned uWSGI worker 4 (pid: 15054, cores: 1)
spawned uWSGI worker 5 (pid: 15055, cores: 1)
我如何启动 uwsgi
/home/django/apps/movehere_env/bin/uwsgi --ini /home/django/apps/movehere_store/prod/uwsgi.ini
【问题讨论】:
【参考方案1】:您不应该在 uwsgi.ini 中的模块参数周围加上引号。这是 Django 文档中的一个错误,已修复。
【讨论】:
以上是关于为啥我的 uWSGI 找不到我的 Django 应用程序?的主要内容,如果未能解决你的问题,请参考以下文章
为啥即使创建了对象,django 也找不到与查询匹配的任何对象