Skip to content Skip to sidebar Skip to footer

Django Apache Wsgi Changes Python Version

I've installed my Django app on an Ubuntu server with Apache2.4.7 and configured it to use py3.5.2 from a virtual environment. However, from what I can see in the errors, it's star

Solution 1:

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.

Solution 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.

Post a Comment for "Django Apache Wsgi Changes Python Version"