3

on django 1.8 In apache error logs am getting

File "..../python2.7/site-packages/django/utils/lru_cache.py", line 28
fasttypes = {int, str, frozenset, type(None)},
SyntaxError: invalid syntax

googling around this seems to be an error you get when running django 1.7+ and not meeting the minimum python requirement of 2.7. however

$ python --version
Python 2.7.3

here is the relevant parts of apache virtual host config.

<VirtualHost <some_ip>:80>       
        WSGIDaemonProcess some_process python-path=/path/to/django-project/main-django-app:/path/to/virtual-env/site-packages/ threads=15 display-name=%{GROUP}
        WSGIProcessGroup some_group

        WSGIScriptAlias / /path/to/django-project/main-django-app/wsgi.py

        <Directory /path/to/django-project/main-django-app>
        <Files wsgi.py>
                Order deny,allow

                # Require all granted
                # for Apache < 2.4
                Allow from all
        </Files>
        </Directory>
</VirtualHost>

does anyone have any idea what the issue might be?

2
  • 2
    Doesn't matter what the command line Python version is. The mod_wsgi package is compiled for a specific Python version and links in the Python shared library. Thus isn't using 'python' from PATH. Your mod_wsgi is likely compiled for Python 2.6. See the documentation code.google.com/p/modwsgi/wiki/… and code.google.com/p/modwsgi/wiki/… Commented Apr 30, 2015 at 7:45
  • right on the button. The default on this system is 2.6.6 (its a managed server and i forgot i had a locally compiled version of 2.7 i was using). I'm waiting to see if recompiling mod_wsgi to 2.7 resolves this. Commented Apr 30, 2015 at 16:07

1 Answer 1

2

You need to install the mod_wsgi for your python version.

If you have not access to the apache installation, mod_wsgi can be installed directly in your virtualenv using pip. Then it can be loaded in your server settings using:

Global settings:

LoadModule wsgi_module /path/to_your_env/path/to/mod_wsgi.so
WSGISocketPrefix run/wsgi
WSGIDaemonProcess 385969

Virtualhost:

WSGIScriptAlias / "/path/to/your/wsgi.py"
<Location />
    WSGIProcessGroup 385969 # this value must be identical to WSGIDaemonProcess
</Location>

Finally, I your wsgi.py file, you'll have to activate the virtualenv.

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

Comments

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.