Kwatog Tech Notes
perpetual newbie, forever learner
Mod_wsgi Encountering invalid syntax in lru_cache.py
If you are scratching your head because of the problem below, you're in a bit of luck because this post may help solve your problem.
File "..../python3.5/site-packages/django/utils/lru_cache.py", line 28 fasttypes = {int, str, frozenset, type(None)}, SyntaxError: invalid syntax
Based on various self-help sites(stackoverflow, google code, etc) I found in the net, this error comes out if you are trying to use an old version of Python(e.g, 2.6) with Django 1.8 or newer.
However if you notice, mod_wsgi is actually calling the correct python which is version 3.5 but still I'm getting the error. So what could the problem be? As it turn out, I compiled mod_wsgi incorrectly by not specifying which version of python to use. So during compilation, the default version of CentOS 6(which I was using) was used and that is python 2.6. And that's where the incompatibility came in. So to correct it, I had to recompile it again with the following steps.
cd /tmp/mod_wsgi-4.4.21 ./configure --with-python=/usr/kwatog/venv/bin/python --with-apxs=/opt/rh/httpd24/root/usr/bin/apxs make make install make clean ldd /opt/rh/httpd24/root/usr/lib64/httpd/modules/mod_wsgi.so
The last step was to confirm if your wsgi is actually using the correct python library.
After restarting Apache, everything's working as expected.