I have a Django app I've been working on debugging using manage.py runserver.
I'm now attempting to serve it with apache/mod_wsgi.
When I try to open the home page I received a 500 error. The log file shows a syntax error in functools.py.
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 <module>
from django.core.wsgi import get_wsgi_application
File "/home/username/.virtualenvs/testing/lib/python3.4/site-packages/django/__init__.py", line 1, in <module>
from django.utils.version import get_version
File "/home/username/.virtualenvs/testing/lib/python3.4/site-packages/django/utils/version.py", line 7, in <module>
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 <module>
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
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.
#testing.conf
<VirtualHost *:80>
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 [email protected]
ServerName django.testing
ServerAlias www.django.testing
Alias /static/ /home/username/projects/django/testing/static/
<Directory />
AllowOverride None
Options -Indexes
</Directory>
<Directory /home/username/projects/django/testing/testing>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
ErrorLog /var/log/apache2/django.testing.log
LogLevel warn
</VirtualHost>
I think I might have a problematic python-path above.
#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()
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.
apt-get install libapache2-mod-wsgiafter a brief search it looks like I should have gottenlibapache2-mod-wsgi-py3instead?