Syntax Error with Django, WSGI, and Apache
<p>I am getting a weird error while trying to run my Django site under Apache using mod_wsgi. I have been working on this for hours to no avail.</p>

<p>FYI: I am also using Mezzanine.</p>

<p>Log:</p>

<pre><code>[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] mod_wsgi (pid=15554): Target WSGI script '/opt/mysite/mysite/wsgi.py' cannot be loaded as Python module.
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] mod_wsgi (pid=15554): Exception occurred processing WSGI script '/opt/mysite/mysite/wsgi.py'.
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] Traceback (most recent call last):
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30]   File "/opt/mysite/mysite/wsgi.py", line 12, in &lt;module&gt;
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30]     from django.core.wsgi import get_wsgi_application
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30]   File "/usr/lib/python2.6/site-packages/django/__init__.py", line 3, in &lt;module&gt;
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30]     from django.utils.version import get_version
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30]   File "/usr/lib/python2.6/site-packages/django/utils/version.py", line 7, in &lt;module&gt;
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30]     from django.utils.lru_cache import lru_cache
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30]   File "/usr/lib/python2.6/site-packages/django/utils/lru_cache.py", line 28
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30]      fasttypes = {int, str, frozenset, type(None)},
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30]                      ^
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30]  SyntaxError: invalid syntax
</code></pre>

<p>httpd.conf for mysite (there are others on the server)</p>

<pre><code># Redirects all HTTP traffic to HTTPS
&lt;VirtualHost *:80&gt;
    #ServerName test-mysite
    #ServerAlias test-mysite mysite.com mysite
    ServerName mysite.com
    ServerAlias mysite test-mysite.com test-mysite

    DocumentRoot /opt/mysite

    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

    WSGIScriptAlias / /opt/mysite/mysite/wsgi.py

&lt;/VirtualHost&gt;

WSGISocketPrefix /var/run/wsgi

&lt;VirtualHost *:443&gt;
    #ServerName test-mysite.com
    #ServerAlias test-mysite
    ServerName mysite.com
    ServerAlias mysite test-mysite.com test-mysite
    ErrorLog /var/log/httpd/ssl_mysite_error_log
    CustomLog /var/log/httpd/ssl_mysite_request_log \
              "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
    TransferLog /var/log/httpd/ssl_mysite_access_log
    LogLevel warn

    WSGIDaemonProcess mysite.com processes=2 threads=15 display-name=%{GROUP}
    WSGIProcessGroup mysite.com

    WSGIScriptAlias / /opt/mysite/mysite/wsgi.py

    &lt;Directory /opt/mysite/mysite&gt;
        Options +FollowSymLinks -Indexes
        AllowOverride All
        order allow,deny
        allow from all
    &lt;/Directory&gt;

    SSLEngine On
    SSLProtocol all -SSLv2
    SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
    SSLCertificateFile /etc/pki/tls/certs/othersite_com.crt
    SSLCertificateKeyFile /etc/pki/tls/private/othersite.com.key
    SSLCertificateChainFile /etc/pki/tls/certs/DigiCertCA.crt
&lt;/VirtualHost&gt;
</code></pre>

<p><code>httpd -V</code> output:</p>

<pre><code>Server version: Apache/2.2.15 (Unix)
Server built:   Jul 12 2016 07:03:49
Server's Module Magic Number: 20051115:25
Server loaded:  APR 1.3.9, APR-Util 1.3.9
Compiled using: APR 1.3.9, APR-Util 1.3.9
Architecture:   64-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=128
 -D HTTPD_ROOT="/etc/httpd"
 -D SUEXEC_BIN="/usr/sbin/suexec"
 -D DEFAULT_PIDLOG="run/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="logs/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"
</code></pre>

<p>How do I fix this?</p>

<pre><code>[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30]   File "/usr/lib/python2.6/site-packages/django/utils/lru_cache.py", line 28
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30]      fasttypes = {int, str, frozenset, type(None)},
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30]                      ^
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30]  SyntaxError: invalid syntax
</code></pre>

<p>Python 2.6 doesn't support <code>set</code> syntax <code>{....}</code></p>

<p>You may <a href="https://www.quora.com/Where-can-I-find-a-version-of-Django-to-use-with-python-2-6" rel="nofollow">use a version of Django that supports Python 2.6</a> but make sure it also supports <code>Mezzanine</code>
OR 
Update your Python installation to <code>2.7</code></p>

python django apache mod-wsgi