0

I'm trying to access a Django application using apache and I'm getting Internal Server Error. I've opened the logs to see what is going on and I found this:

[Thu Jun 23 03:10:03 2016] [notice] suEXEC mechanism enabled (wrapper:  /usr/sbin/suexec)
[Thu Jun 23 03:10:03 2016] [notice] Digest: generating secret for digest authentication ...
[Thu Jun 23 03:10:03 2016] [notice] Digest: done
[Thu Jun 23 03:10:03 2016] [notice] Apache/2.2.15 (Unix) DAV/2 mod_wsgi/3.2    Python/2.6.6 configured -- resuming normal operations
[Thu Jun 23 03:10:10 2016] [error] [client 197.41.248.175] mod_wsgi (pid=5612): Target WSGI script '/home/TaskManagement/teamwork/wsgi.py' cannot be loaded as Python module.
[Thu Jun 23 03:10:10 2016] [error] [client 197.41.248.175] mod_wsgi (pid=5612): Exception occurred processing WSGI script '/home/TaskManagement/teamwork/wsgi.py'.
[Thu Jun 23 03:10:10 2016] [error] [client 197.41.248.175] Traceback (most recent call last):
[Thu Jun 23 03:10:10 2016] [error] [client 197.41.248.175]   File "/home/TaskManagement/teamwork/wsgi.py", line 15, in <module>
[Thu Jun 23 03:10:10 2016] [error] [client 197.41.248.175]     from django.core.wsgi import get_wsgi_application
[Thu Jun 23 03:10:10 2016] [error] [client 197.41.248.175]   File "/home/py3venv/lib/python3.4/site-packages/django/__init__.py", line 1, in <module>
[Thu Jun 23 03:10:10 2016] [error] [client 197.41.248.175]     from django.utils.version import get_version
[Thu Jun 23 03:10:10 2016] [error] [client 197.41.248.175]   File "/home/py3venv/lib/python3.4/site-packages/django/utils/version.py", line 7, in <module>
[Thu Jun 23 03:10:10 2016] [error] [client 197.41.248.175]     from django.utils.lru_cache import lru_cache
[Thu Jun 23 03:10:10 2016] [error] [client 197.41.248.175]   File "/home/py3venv/lib/python3.4/site-packages/django/utils/lru_cache.py", line 28
[Thu Jun 23 03:10:10 2016] [error] [client 197.41.248.175]      fasttypes = {int, str, frozenset, type(None)},
[Thu Jun 23 03:10:10 2016] [error] [client 197.41.248.175]                      ^
[Thu Jun 23 03:10:10 2016] [error] [client 197.41.248.175]  SyntaxError: invalid syntax

I'm using python 3.4, Django 1.9, apache 2.2. and here is my apache configuration:

WSGISocketPrefix /var/run/wsgi
WSGIScriptAlias / /home/TaskManagement/teamwork/wsgi.py process-group=hrm.jodod.info
WSGIDaemonProcess hrm.jodod.info python-path=/home/TaskManagement:/home/py3venv/lib/python3.4/site-packages
WSGIProcessGroup hrm.jodod.info

Alias /robots.txt /home/TaskManagement/robots.txt
Alias /favicon.ico /home/TaskManagement/favicon.ico
Alias /static/ /home/TaskManagement/static/

<Directory /path/to/mysite.com/static>
Order deny,allow
Allow from all
</Directory>

<Directory /home/TaskManagement/teamwork>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>

and here is my wsgi.py file:

import os
import sys

sys.path.append('/home/TaskManagement')
sys.path.append('/home/TaskManagement/teamwork')
from django.core.wsgi import get_wsgi_application

os.environ["DJANGO_SETTINGS_MODULE"] = "{{ project_name }}.settings"
application = get_wsgi_application()

Can anybody figure out what am I doing wrong?

2 Answers 2

2
Python/2.6.6 configured -- resuming normal operations

Looks like your mod_wsgi is compiled against Python 2.6.6 and you're trying to run Python3 code with it. The Set syntax you are seeing in the error appeared in Py3. Recompile mod_wsgi and try again.

Sign up to request clarification or add additional context in comments.

1 Comment

This was the problem. I had to install the source of mod_wsgi and compiled it against python 3.4 and it worked.
1

Your wsgi.py line 9 has to be

os.environ["DJANGO_SETTINGS_MODULE"] = "teamwork.settings" 

if the directory it's stored is called teamwork (your project's name)

also in your manage.py it has to be "teamwork.settings"

1 Comment

You can't use Django's template syntax within python files

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.