Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django and Python + uWSGI

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

like image 699
San4ez Avatar asked Sep 23 '10 05:09

San4ez


2 Answers

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.

like image 137
aaronasterling Avatar answered Sep 21 '22 01:09

aaronasterling


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
like image 25
raidsan Avatar answered Sep 22 '22 01:09

raidsan