[Django]-Django Apache wsgi changes python version

12đź‘Ť

âś…

The mod_wsgi module for Apache is compiled for a specific Python version. You cannot make it run using a different Python version by pointing it at a Python virtual environment for a different Python version. This is cleared mentioned in the mod_wsgi documentation about use of Python virtual environments at:

The only way you can have mod_wsgi run as Python 3.5, if it was original compiled for Python 3.4, is to uninstall that version of mod_wsgi and build/install a version of mod_wsgi compiled for Python 3.5.

2đź‘Ť

The source of the problem was Graham Dumpleton’s answer.
I just want to give some more information in case it helps someone facing the same problem as me.

There’s no official repo for Python 3.5.2 in Ubuntu server 14.04.
Rather than using some unsupported repo like this one, I compiled Python 3.5.2 from source using this very simple tutorial here.
After jumping through many hoops, I couldn’t install mod_wsgi for Python 3.5.2 because of a library path that was different.

Having already spent too much time on this, I uninstalled everything: Python, Apache, libraries and installed everything from scratch, using Python 3.4 this time.

It’s officially supported for Ubuntu 14.04 and for my project, I noticed no compatibility issues.

So here’s my shortlist for what to install:
from apt:
python3,
python3-pip,
apache2,
apache2-dev,
libapache2-mod-wsgi-py3 and
from pip:
Django,
mod-wsgi,
virtualenv (if you plan to use a venv).

Then just configure “/etc/apache2/apache.conf”, run “apache2ctl configtest” and restart the service.
For extra help see this guide here.

👤rwms

Leave a comment