Back after mod_wsgi & Python 3

The Python-powered bits of this website (my portfolio as well as the redirection to the blog that’s active for ‘/’ unfortunately) threw up HTTP error 500’s since Nov 18. Unfortunately I only now noticed this, though I’m not sure if Django’s email reporting system would’ve alerted me about this.

I got the following errors:

[usual headers] mod_wsgi (pid=14552): Target WSGI script '/<path to django project>/wsgi.py' cannot be loaded as Python module.
[usual headers] mod_wsgi (pid=14552): Exception occurred processing WSGI script '/<path to django project>/wsgi.py'.
[usual headers] Traceback (most recent call last):
[usual headers]   File "/<path to django>/django/django/core/handlers/wsgi.py", line 4, in <module>
[usual headers]     from cStringIO import StringIO
[usual headers] ImportError: No module named 'cStringIO'
[usual headers] 
[usual headers] During handling of the above exception, another exception occurred:
[usual headers] 
[usual headers] Traceback (most recent call last):
[usual headers]   File "/<path to django project>/wsgi.py", line 25, in <module>
[usual headers]     from django.core.handlers.wsgi import WSGIHandler
[usual headers]   File "/<path to django>/django/core/handlers/wsgi.py", line 6, in <module>
[usual headers]     from StringIO import StringIO
[usual headers] ImportError: No module named 'StringIO'

I guess what happened is that an upgrade switched mod_wsgi to use Python 3 rather than Python 2, and for some reason Arch Linux didn’t replace the mod_wsgi package with the new mod_wsgi2 package, which uses Python 2. I must admit, the above is a rather peculiar way of beign notified that your WSGI process is using the wrong Python version.

Lesson learned: monitor your server automatically.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.