title: Django - python3.4 virtualenv - apache
body: <p>I have a Django app I've been working on debugging using manage.py runserver.</p>
  
  <p>I'm now attempting to serve it with apache/mod_wsgi.</p>
  
  <p>When I try to open the home page I received a 500 error. The log file shows a syntax error in functools.py.</p>
  
  <pre><code>mod_wsgi (pid=28016): Target WSGI script '/home/username/projects/django/testing/testing/wsgi.py' cannot be loaded as Python module.
  mod_wsgi (pid=28016): Exception occurred processing WSGI script '/home/username/projects/django/testing/testing/wsgi.py'.
  Traceback (most recent call last):
  File "/home/username/projects/django/testing/testing/wsgi.py", line 12, in &lt;module&gt;
    from django.core.wsgi import get_wsgi_application
  File "/home/username/.virtualenvs/testing/lib/python3.4/site-packages/django/__init__.py", line 1, in &lt;module&gt;
    from django.utils.version import get_version
  File "/home/username/.virtualenvs/testing/lib/python3.4/site-packages/django/utils/version.py", line 7, in &lt;module&gt;
    from django.utils.lru_cache import lru_cache
  File "/home/username/.virtualenvs/testing/lib/python3.4/site-packages/django/utils/lru_cache.py", line 2, in &lt;module&gt;
    from functools import lru_cache
  File "/home/username/.virtualenvs/testing/lib/python3.4/functools.py", line 291
    cls_or_self, *rest = args
                 ^
  SyntaxError: invalid syntax
  </code></pre>
  
  <p>As far as I can tell that is valid python3.4 syntax. So I'm not entirely sure if I have WSGI configured correctly to use my virtualenv.</p>
  
  <pre><code>#testing.conf
  &lt;VirtualHost *:80&gt;
      WSGIDaemonProcess django.testing.username.vni user=username group=username python-path=/home/username/.virtualenvs/testing/lib/python3.4/site-packages:/home/username/.virtualenvs/testing/lib/python3.4:/home/username/.virtualenvs/testing
      WSGIProcessGroup django.testing.username.vni
  
      WSGIScriptAlias / /home/username/projects/django/testing/testing/wsgi.py
  
      ServerAdmin username@webserver.com
      ServerName django.testing
      ServerAlias www.django.testing
  
      Alias /static/ /home/username/projects/django/testing/static/
  
      &lt;Directory /&gt;
          AllowOverride None
          Options -Indexes
      &lt;/Directory&gt;
  
      &lt;Directory /home/username/projects/django/testing/testing&gt;
          &lt;Files wsgi.py&gt;
              Require all granted
          &lt;/Files&gt;
      &lt;/Directory&gt;
  
      ErrorLog /var/log/apache2/django.testing.log
      LogLevel warn
  
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>I think I might have a problematic python-path above.</p>
  
  <pre><code>#wsgi.py
  import os
  
  from django.core.wsgi import get_wsgi_application
  
  import sys
  sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/..")
  sys.path.append(os.path.dirname(os.path.abspath(__file__)))
  
  #os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testing.settings")
  os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
  
  application = get_wsgi_application()
  </code></pre>
  
  <p>I'm not sure if I've handled the sys.path.append()'s properly or the DJANGO_SETTINGS_MODULE. They are as they are to hack around a few other errors I ran into.</p>