这篇文章解释的特别好--> uwsgi no python application found错误的解决(python3+centos7)
1. 错误
virtualenv
环境中启动uWSGI
后,访问报错:
no python application found, check your startup logs for errors
2.解决
这里的问题是,当执行wsgi.py时,它缺少来自virtualenv的site-packages包。如果你已经激活了你的virtualenv,并完成了pip install django那么一切都很好。你有必要的django p ackages。你必须将你的项目目录和你的virtualenv站点包附加到sys.path列表。
# =====================
# wsgi.py file begin
import os, sys
# add the hellodjango project path into the sys.path
sys.path.append('<PATH_TO_MY_DJANGO_PROJECT>/hellodjango') # 添加你的项目绝对路径
# sys.path.append('/sdb/pyweb/djcode/website')
# add the virtualenv site-packages path to the sys.path
sys.path.append('<PATH_TO_VIRTUALENV>/Lib/site-packages') # 添加你虚拟环境包绝对路径
# sys.path.append('/sdb/pyweb/djcode/lib/python2.7/site-packages')
# poiting to the project settings
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hellodjango.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
# wsgi.py file end
# ===================
网友评论