[英]No module named django.core.wsgi with nginx, uwsgi and virtualenv
uwsgi.ini uwsgi.ini
[uwsgi]
vhost = true
plugin = python
socket = /tmp/pjwards.sock
master = true
enable-threads = true
processes = 2
wsgi-file = /home/ubuntu/workspace/ward/www/fb_archive/wsgi.py
virtualenv = /home/ubuntu/.virtualenvs/fb_archive
chdir = /home/ubuntu/workspace/ward/www/fb_archive
touch-reload = /home/ubuntu/workspace/ward/www/reload
wsgi.py wsgi.py
import site
import os
import sys
from django.core.wsgi import get_wsgi_application
from mezzanine.utils.conf import real_project_name
site.addsitedir('/home/ubuntu/.virtualenvs/fb_archive/lib/python3.4/site-packages')
sys.path.insert(0, '/home/ubuntu/workspace/ward')
os.environ.setdefault("DJANGO_SETTINGS_MODULE",
"%s.settings" % real_project_name("fb_archive"))
application = get_wsgi_application()
uWSGI does not work by ImportError: No module named django.core.wsgi
. uWSGI不能通过ImportError: No module named django.core.wsgi
。 I use nginx, uwsgi and virtualenv with python3. 我将nginx,uwsgi和virtualenv与python3结合使用。
Traceback (most recent call last):
File "/home/ubuntu/workspace/ward/www/fb_archive/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)
You're doing the import before you've added your virtualenv to the pythonpath, so naturally the module can't be found. 在将virtualenv添加到pythonpath之前,您需要进行导入,因此自然找不到该模块。 Move the import to just before the get_wsgi_application()
call itself. 将导入移动到get_wsgi_application()
调用之前。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.