Django 和 Python + uWSGI
使用指令我尝试连接Python+<强>uWSGI。
我在文件夹 /home/sanya/django/pasteurl 中创建了默认项目。 但是,在浏览器中打开它,我得到的
uWSGI Error
wsgi application not found
日志包含以下内容:
binding on TCP port: 9001
your server socket listen backlog is limited to 64 connections
added /home/sanya/django/pasteurl to pythonpath.
initializing hooks...done.
...getting the applications list from the 'django' module...
uwsgi.applications dictionary is not defined, trying with the "applications" one...
applications dictionary is not defined, trying with the "application" callable.
static applications not defined, you have to use the dynamic one...
spawned uWSGI master process (pid: 7637)
spawned uWSGI worker 1 (pid: 7646)
spawned uWSGI worker 2 (pid: 7647)
spawned uWSGI worker 3 (pid: 7648)
spawned uWSGI worker 4 (pid: 7649)
文件 /home/sanya/django/pasteurl/django.wsgi
import os
import django.core.handlers.wsgi
# init django settings
os.environ['DJANGO_SETTINGS_MODULE'] = 'pasteurl.settings'
# define wsgi app
application = django.core.handlers.wsgi.WSGIHandler()
# mount this application at the webroot
# applications = { '/': 'application' }
正如我意识到的,这个应用程序有问题词典
Using instruction I try to connect Python + uWSGI.
I made default project in a folder /home/sanya/django/pasteurl.
However, have opened it in a browser I get
uWSGI Error
wsgi application not found
Logs contain the following:
binding on TCP port: 9001
your server socket listen backlog is limited to 64 connections
added /home/sanya/django/pasteurl to pythonpath.
initializing hooks...done.
...getting the applications list from the 'django' module...
uwsgi.applications dictionary is not defined, trying with the "applications" one...
applications dictionary is not defined, trying with the "application" callable.
static applications not defined, you have to use the dynamic one...
spawned uWSGI master process (pid: 7637)
spawned uWSGI worker 1 (pid: 7646)
spawned uWSGI worker 2 (pid: 7647)
spawned uWSGI worker 3 (pid: 7648)
spawned uWSGI worker 4 (pid: 7649)
File /home/sanya/django/pasteurl/django.wsgi
import os
import django.core.handlers.wsgi
# init django settings
os.environ['DJANGO_SETTINGS_MODULE'] = 'pasteurl.settings'
# define wsgi app
application = django.core.handlers.wsgi.WSGIHandler()
# mount this application at the webroot
# applications = { '/': 'application' }
As I realised, it's something wrong with this application dictionary
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
FWIW,查看源代码,从第 1997 行,我们看到如果 uWSGI 找不到
applications
字典,它会发出您收到的错误消息的确切序列。查看您的 django.wsgi 文件,我们看到该行
已被注释掉。我想知道我们能对此做些什么;)
顺便说一句,我使用 谷歌。在谷歌上搜索引号中的错误消息通常是一件好事。当我点击该链接并意识到我很幸运能够直接从 google 找到源代码(这种情况越来越多)时,我按 Ctrl-F 进行“在页面上查找”,然后在浏览器中重新输入错误消息页面搜索功能直接引导我到相关行。
FWIW, looking at the source code, starting at line 1997, we see that uWSGI emits the exact sequence of error messages that you are receiving if it cannot find an
applications
dictionary.Looking at your
django.wsgi
file, we see that the line,is commented out. I wonder what we could do about that ;)
BTW, I found the source code using google. Googling for error messages in quotes is often a good thing to do. After I clicked on that link and realized that I was lucky enough to have found the source code straight from google (happens more and more), I pressed Ctrl-F for 'find on page' and re-entered the error message in my browser's on page search facility which led me straight to the relevant lines.
同样的问题,请在这里备注:
检查nginxconf:
确保:
1.sompath/somefile.py必须存在
2.它必须使用“.py”作为范围文件名
3.不要使用全名,例如“somefile.py” ,或者发生了相同的错误,并且 uwsgi 日志文件中有错误日志:
same issue, remark here:
check nginx conf:
make sure:
1.sompath/somefile.py must exist
2.it must use ".py" as extent file name
3.don't use full name such as "somefile.py", or same error happend ocer, and has error log in uwsgi log file: