Django 和 Python + uWSGI

发布于 2024-09-25 05:14:49 字数 1456 浏览 10 评论 0原文

使用指令我尝试连接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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

失与倦" 2024-10-02 05:14:49

FWIW,查看源代码,从第 1997 行,我们看到如果 uWSGI 找不到 applications 字典,它会发出您收到的错误消息的确切序列。

查看您的 django.wsgi 文件,我们看到该行

`applications = {'/': 'application'} 

已被注释掉。我想知道我们能对此做些什么;)

顺便说一句,我使用 谷歌。在谷歌上搜索引号中的错误消息通常是一件好事。当我点击该链接并意识到我很幸运能够直接从 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,

`applications = {'/': 'application'} 

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.

时光沙漏 2024-10-02 05:14:49

同样的问题,请在这里备注:

uWSGI Error
wsgi application not found

检查nginxconf:

uwsgi_param UWSGI_CHDIR  somepath
wsgi_param UWSGI_SCRIPT  somefile

确保:

1.sompath/somefile.py必须存在

2.它必须使用“.py”作为范围文件名

3.不要使用全名,例如“somefile.py” ,或者发生了相同的错误,并且 uwsgi 日志文件中有错误日志:

ImportError: No module named py

same issue, remark here:

uWSGI Error
wsgi application not found

check nginx conf:

uwsgi_param UWSGI_CHDIR  somepath
wsgi_param UWSGI_SCRIPT  somefile

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:

ImportError: No module named py
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文