Django error with WSGI

201 views
Skip to first unread message

James.DeMichele

unread,
Jan 10, 2011, 12:14:12 AM1/10/11
to modwsgi
Hello all,

I was hoping someone here might be able to help me figure out what is
wrong with my configuration. Here's my current setup:

Windows 7
Python 2.6.6
Psycopg2-2.3.1
Postgres 9.0
mod_wsgi-win32-ap22py26-3.3.so
Apache 2.2
Django 1.2

First off, I have Django functioning correctly with the dev server,
and can make a call to the database correctly. Now, I wanted to get
WSGI to work with Django. Also, I am able to get the Hello World WSGI
example found here (http://code.google.com/p/modwsgi/wiki/
QuickConfigurationGuide) to work correctly within my Django project
and have it print out "Hello World".

Here's my Apache configuration

WSGIPythonHome "C:/Python"
<VirtualHost *:80>
ServerName sng.dev.com
ServerAlias sng.dev.com

LogLevel info

Alias /media/ C:/code/sng/media

<Directory C:/code/sng/media>
Order deny,allow
Allow from all
</Directory>

WSGIScriptAlias / "C:/code/sng/wsgi/django.wsgi"

<Directory C:/code/sng/wsgi/>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

Here's what I have in my django.wsgi file:

---------------
path = 'C:\code'
if path not in sys.path:
sys.path.append('C:\code')
path = 'C:\code'
if path not in sys.path:
sys.path.append('C:\code\sng')

os.environ['DJANGO_SETTINGS_MODULE'] = 'sng.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
---------------

Here's the error stack trace:

[Sun Jan 09 23:07:46 2011] [error] [client 127.0.0.1] mod_wsgi
(pid=6308): Target WSGI script 'C:/code/sng/wsgi/django.wsgi' cannot
be loaded as Python module.
[Sun Jan 09 23:07:46 2011] [error] [client 127.0.0.1] mod_wsgi
(pid=6308): Exception occurred processing WSGI script 'C:/code/sng/
wsgi/django.wsgi'.
[Sun Jan 09 23:07:46 2011] [error] [client 127.0.0.1] Traceback (most
recent call last):
[Sun Jan 09 23:07:46 2011] [error] [client 127.0.0.1] File "C:/code/
sng/wsgi/django.wsgi", line 33, in <module>
[Sun Jan 09 23:07:46 2011] [error] [client 127.0.0.1] import
django.db.backends.postgresql_psycopg2
[Sun Jan 09 23:07:46 2011] [error] [client 127.0.0.1] File "C:\
\Python\\lib\\site-packages\\django\\db\\__init__.py", line 77, in
<module>
[Sun Jan 09 23:07:46 2011] [error] [client 127.0.0.1] connection =
connections[DEFAULT_DB_ALIAS]
[Sun Jan 09 23:07:46 2011] [error] [client 127.0.0.1] File "C:\
\Python\\lib\\site-packages\\django\\db\\utils.py", line 92, in
__getitem__
[Sun Jan 09 23:07:46 2011] [error] [client 127.0.0.1] backend =
load_backend(db['ENGINE'])
[Sun Jan 09 23:07:46 2011] [error] [client 127.0.0.1] File "C:\
\Python\\lib\\site-packages\\django\\db\\utils.py", line 50, in
load_backend
[Sun Jan 09 23:07:46 2011] [error] [client 127.0.0.1] raise
ImproperlyConfigured(error_msg)
[Sun Jan 09 23:07:46 2011] [error] [client 127.0.0.1]
ImproperlyConfigured: 'django.db.backends.postgresql_psycopg2' isn't
an available database backend.
[Sun Jan 09 23:07:46 2011] [error] [client 127.0.0.1] Try using
django.db.backends.XXX, where XXX is one of:
[Sun Jan 09 23:07:46 2011] [error] [client 127.0.0.1] 'dummy',
'mysql', 'oracle', 'postgresql', 'postgresql_psycopg2', 'sqlite3'
[Sun Jan 09 23:07:46 2011] [error] [client 127.0.0.1] Error was:
cannot import name utils

Graham Dumpleton

unread,
Jan 10, 2011, 5:26:31 PM1/10/11
to mod...@googlegroups.com
Django can hide the actual underlying error message in some
circumstances. The problem may be this one:

http://groups.google.com/group/modwsgi/browse_thread/thread/13b4a5faa962d77/dd4d6a03afbe16b6
http://psycopg.lighthouseapp.com/projects/62710/tickets/20
http://archives.postgresql.org/psycopg/2011-01/msg00009.php

The issue as it presents with your error has I believe come up on the
list before, so you might search through the archives in Google
Groups. Don't remember if it was linked to this issue.

Graham

> --
> You received this message because you are subscribed to the Google Groups "modwsgi" group.
> To post to this group, send email to mod...@googlegroups.com.
> To unsubscribe from this group, send email to modwsgi+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en.
>
>

James DeMichele

unread,
Jan 10, 2011, 5:44:03 PM1/10/11
to mod...@googlegroups.com
Thanks, Graham.

Yeah I continued to dig around and I think this page gives the most explanation:

http://psycopg.lighthouseapp.com/projects/62710/tickets/20

-Jamie

Алёна Медведева

unread,
Feb 17, 2011, 11:21:41 AM2/17/11
to modwsgi
James, what is solution? how can i use the patch?

On 11 янв, 01:44, James DeMichele <james.demich...@gmail.com> wrote:
> Thanks, Graham.
>
> Yeah I continued to dig around and I think this page gives the most
> explanation:
>
> http://psycopg.lighthouseapp.com/projects/62710/tickets/20
>
> -Jamie
>
> On Mon, Jan 10, 2011 at 4:26 PM, Graham Dumpleton <
>
> graham.dumple...@gmail.com> wrote:
> > Django can hide the actual underlying error message in some
> > circumstances. The problem may be this one:
>
> >http://groups.google.com/group/modwsgi/browse_thread/thread/13b4a5faa...
> >  http://psycopg.lighthouseapp.com/projects/62710/tickets/20
> >  http://archives.postgresql.org/psycopg/2011-01/msg00009.php
>
> > The issue as it presents with your error has I believe come up on the
> > list before, so you might search through the archives in Google
> > Groups. Don't remember if it was linked to this issue.
>
> > Graham
>
> > On 10 January 2011 16:14, James.DeMichele <james.demich...@gmail.com>
> > modwsgi+u...@googlegroups.com<modwsgi%2Bunsu...@googlegroups.com>
> > .
> > > For more options, visit this group at
> >http://groups.google.com/group/modwsgi?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "modwsgi" group.
> > To post to this group, send email to mod...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > modwsgi+u...@googlegroups.com<modwsgi%2Bunsu...@googlegroups.com>
> > .

Graham Dumpleton

unread,
Feb 18, 2011, 4:20:33 AM2/18/11
to mod...@googlegroups.com, Алёна Медведева
See:

https://groups.google.com/d/topic/modwsgi/E3-IrGkn31k/discussion

Graham

2011/2/18 Алёна Медведева <alena....@gmail.com>:

> To unsubscribe from this group, send email to modwsgi+u...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages