0

I'm working on running Django + httpd using mod_wsgi.

I've read up the docs and configured httpd.conf as required. I'm running Python2.7 on Centos5.5

I'm getting a strange "syntax" error which looks like a version conflict to me. Any pointers ?

Here are my Apache error logs:

[Tue Aug 27 19:12:01 2013] [error] [client 10.104.22.85] mod_wsgi (pid=32765): Target WSGI script '/home/sbose/PATH/TO/wsgi.py' cannot be loaded as Python module.
[Tue Aug 27 19:12:01 2013] [error] [client 10.104.22.85] mod_wsgi (pid=32765): Exception occurred processing WSGI script '/home/sbose/PATH/TO/wsgi.py'.
[Tue Aug 27 19:12:01 2013] [error] [client 10.104.22.85] Traceback (most recent call last):
[Tue Aug 27 19:12:01 2013] [error] [client 10.104.22.85]   File "/home/sbose/PATH/TO/wsgi.py", line 10, in ?
[Tue Aug 27 19:12:01 2013] [error] [client 10.104.22.85]     import django.core.handlers.wsgi
[Tue Aug 27 19:12:01 2013] [error] [client 10.104.22.85]   File "/usr/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 84
[Tue Aug 27 19:12:01 2013] [error] [client 10.104.22.85]      self.buffer = b''
[Tue Aug 27 19:12:01 2013] [error] [client 10.104.22.85]                      ^
[Tue Aug 27 19:12:01 2013] [error] [client 10.104.22.85]  SyntaxError: invalid syntax

UPDATE: I just figured out that Apache was running Python2.4 Also, FYI,I had installed mod_wsgi with yum.

Thanks.

4
  • recheck the traceback, the problem may be is from there Commented Aug 27, 2013 at 14:07
  • Thanks,I get that. That is not the code I wrote :-| Commented Aug 27, 2013 at 14:16
  • 1
    You might want to see why Target WSGI script '/home/sbose/PATH/TO/wsgi.py' cannot be loaded as Python module error is occuring. May be this post ? Commented Aug 27, 2013 at 14:17
  • Thanks, but this : "ImportError: No module named django.core.handlers.wsgi" is clearly not my case :) Commented Aug 27, 2013 at 14:22

1 Answer 1

1

b strings were introduced between 2.4 and 2.7 (I don't know the exact release).

To check your Python version:

>>> import sys
>>> sys.version
'2.4.4 (#1, Jul 12 2013, 10:47:50) \n[GCC 4.7.3]'

Log it, if you want it to be in your apache log files.

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

5 Comments

Do you even understand this code? Otherwise, b is not a variable defined in the scope, so it must be self.buffer = ''
This is what the b is supposed to be implying stackoverflow.com/questions/6269765/…
What version of Python are you running? It doesn't work in Python 2.4 here, but works in Python 2.7
I have both installed ( 2.4 was the default ). Any idea how I should be checking which one is being used by Apache?

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.