Apache日志文件中wsgi.py中的语法错误

时间:2013-08-27 13:59:57

标签: python django apache mod-wsgi

我正在使用mod_wsgi运行 Django + httpd。

我已经阅读了文档并根据需要配置了httpd.conf。我在Centos5.5上运行Python2.7

我收到一个奇怪的“语法”错误,看起来像版本冲突给我。有什么指针吗?

以下是我的Apache错误日志:

[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

更新 我只是发现Apache正在运行Python2.4 另外,仅供参考,我已经用yum安装了mod_wsgi。

感谢。

1 个答案:

答案 0 :(得分:1)

b字符串介于2.4和2.7之间(我不知道确切的发布)。

检查您的Python版本:

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

如果您希望它在您的apache日志文件中,请记录它。