Django mod_wsgi 语法错误

Django mod_wsgi Syntax Error

我在我的 Apache 中得到以下内容 error.log

[Mon Dec 14 21:23:05 2015] [notice] caught SIGTERM, shutting down
[Mon Dec 14 21:23:06 2015] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Dec 14 21:23:06 2015] [notice] Digest: generating secret for digest authentication ...
[Mon Dec 14 21:23:06 2015] [notice] Digest: done
[Mon Dec 14 21:23:06 2015] [notice] Apache/2.2.15 (Unix) DAV/2 mod_wsgi/3.2 Python/2.6.6 configured -- resuming normal operations
[Mon Dec 14 21:23:07 2015] [error] [client 10.77.1.104] mod_wsgi (pid=2316): Target WSGI script '/opt/myproject/myproject/wsgi.py' cannot be loaded as Python module.
[Mon Dec 14 21:23:07 2015] [error] [client 10.77.1.104] mod_wsgi (pid=2316): Exception occurred processing WSGI script '/opt/myproject/myproject/wsgi.py'.
[Mon Dec 14 21:23:07 2015] [error] [client 10.77.1.104] Traceback (most recent call last):
[Mon Dec 14 21:23:07 2015] [error] [client 10.77.1.104]   File "/opt/myproject/myproject/wsgi.py", line 12, in <module>
[Mon Dec 14 21:23:07 2015] [error] [client 10.77.1.104]     from django.core.wsgi import get_wsgi_application
[Mon Dec 14 21:23:07 2015] [error] [client 10.77.1.104]   File "/opt/myproject_app/lib/python2.7/site-packages/django/__init__.py", line 1, in <module>
[Mon Dec 14 21:23:07 2015] [error] [client 10.77.1.104]     from django.utils.version import get_version
[Mon Dec 14 21:23:07 2015] [error] [client 10.77.1.104]   File "/opt/myproject_app/lib/python2.7/site-packages/django/utils/version.py", line 7, in <module>
[Mon Dec 14 21:23:07 2015] [error] [client 10.77.1.104]     from django.utils.lru_cache import lru_cache
[Mon Dec 14 21:23:07 2015] [error] [client 10.77.1.104]   File "/opt/myproject_app/lib/python2.7/site-packages/django/utils/lru_cache.py", line 28
[Mon Dec 14 21:23:07 2015] [error] [client 10.77.1.104]      fasttypes = {int, str, frozenset, type(None)},
[Mon Dec 14 21:23:07 2015] [error] [client 10.77.1.104]                      ^
[Mon Dec 14 21:23:07 2015] [error] [client 10.77.1.104]  SyntaxError: invalid syntax

我不知道问题出在哪里。我的 virtualenv 文件在 /opt/myproject_app

我的 Django 项目在 /opt/myproject

django.conf

ServerName serverabc

WSGIScriptAlias / /opt/myproject/myproject/wsgi.py

Alias /static/ /var/www/myproject/static/
Alias /media/ /var/www/myproject/media/

<Directory /var/www/myproject>
    Order allow,deny
    Allow from all
</Directory>

<Directory /var/www/myproject/static>
    Order deny,allow
    Allow from all
</Directory>

<Directory /opt/myproject/myproject>
    <Files wsgi.py>
        Order deny,allow
        Allow from all
    </Files>
</Directory>

WSGIDaemonProcess myproject.com python-path=/opt/myproject:/opt/myproject_app/lib/python2.7/site-packages
WSGIProcessGroup myproject.com

The last version of Django that worked with Python 2.6 was 1.6. 要么升级 Python 并重建 mod_wsgi,要么降级 Django。