0

I am trying to setup django python on wamp ( the latest). With all configurations done I get a 500 internal error. When I check my error logs I see that there is a syntax error and I compare with what I find from google and its the same. I have copied it here so please tell me what the problem is please. For background I am using Windows 7 64bit Professional with wamp 2.2 32bit. here are my configs:

LoadModule wsgi_module modules/mod_wsgi.so
    
WSGIScriptAlias / "d:/projects/testproject/django.wsgi"
[Directory D:/projects/testproject]
Order deny,allow
Allow from all
[/Directory]

This is my django.wsgi:


import os
import os.path
import sys
sys.path.append('d:/projects/') 
os.environ['DJANGO_SETTINGS_MODULE'] = 'testProject.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()


[Wed Mar 28 01:11:33 2012] [error] [client 127.0.0.1] mod_wsgi (pid=680, process='', application='localhost|'): Failed to parse WSGI script file 'D:/projects/testproject/django.wsgi'.
[Wed Mar 28 01:11:33 2012] [error] [client 127.0.0.1] mod_wsgi (pid=680): Exception occurred processing WSGI script 'D:/projects/testproject/django.wsgi'.
[Wed Mar 28 01:11:33 2012] [error] [client 127.0.0.1]   File "D:/projects/testproject/django.wsgi", line 2
[Wed Mar 28 01:11:33 2012] [error] [client 127.0.0.1]     sys.path.append('d:/projects/') os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'
[Wed Mar 28 01:11:33 2012] [error] [client 127.0.0.1]                                      ^
[Wed Mar 28 01:11:33 2012] [error] [client 127.0.0.1] SyntaxError: invalid syntax
[Wed Mar 28 01:11:57 2012] [notice] Parent: Received shutdown signal -- Shutting down the server.

I am sure there is something I am missing. Please help.

EDIT:


[Wed Mar 28 12:39:11 2012] [error] [client 127.0.0.1] mod_wsgi (pid=3156, process='', application='localhost|'): Failed to parse WSGI script file 'D:/projects/testproject/django.wsgi'.
[Wed Mar 28 12:39:11 2012] [error] [client 127.0.0.1] mod_wsgi (pid=3156): Exception occurred processing WSGI script 'D:/projects/testproject/django.wsgi'.
[Wed Mar 28 12:39:11 2012] [error] [client 127.0.0.1]   File "D:/projects/testproject/django.wsgi", line 2
[Wed Mar 28 12:39:11 2012] [error] [client 127.0.0.1]     sys.path.append('d:/projects/') os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'
[Wed Mar 28 12:39:11 2012] [error] [client 127.0.0.1]                                      ^
[Wed Mar 28 12:39:11 2012] [error] [client 127.0.0.1] SyntaxError: invalid syntax

In the error logs it puts a caret (^) under os.environ saying there is a syntax error. So I did what graham suggested and made sure of my line endings but still errors is all I get. Error 500 Internal Error.

2
  • Can you post D:/projects/testproject/django.wsgi Commented Mar 28, 2012 at 0:51
  • edited my code snippets and added the django.wsgi file thanks pastylegs Commented Mar 28, 2012 at 0:58

2 Answers 2

1

You likely have mixed line endings in the file. IOW, mixture of \r\n and \n, or maybe even \r. Line endings need to be consistent.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks but I even made sure that there were no new lines after the last line in my wsgi file and still I get error 500 internal error.I actually don't know what else to do. I could install a django stack but isn't that overkill? I have never been able to do this i have tried a few times and its the same error always. Thanks for trying graham.
1

try in wsgi.py:

import os, sys
sys.path.append(os.sep.join(os.path.abspath(__file__).split(os.sep)[:-2]))
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testproject.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

and then in httpd.conf:

WSGIScriptAlias /test "d:\projects\testproject\testproject\wsgi.py"

Finally you should create an alias Alias /test/ "c:/projects/testproject/"

<Directory "c:/projects/testproject/">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Order allow,deny
    Allow from all
</Directory>

And that's all. Now go to localhost/test

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.