I am running apache2 (mod-wsgi) on Ubuntu 14.10. I am getting 500 Internal Server Error when serving my web-site. I am also using Flask and Python 3.4, and virtual environment. It appears that Ubuntu has python 2.7 as default, and I need to configure apache2 to look for virtual environment with Python 3.4. Otherwise, I am getting 500 error. I checked apache2 error log file and it shows that the reason for it is because app.wsgi file cannot import flask. And in turn reason for not being able to import flask is because it's in python 3.4 environment while apache2 is in python 2.7.

I tried to fix it by adding the following line into apache2.conf file:

WSGIPythonHome /path/to/my/virt/env

But it does not work.

  • Welcome to Server Fault! Thank you for posting here. Getting good answers requires the effort of writing a good question and as it stands now yours appears to be missing sufficient detail to provide you with an optimal solution. The exact error message from your log files typically helps. And maybe this is of interest. – HBruijn Jan 26 '15 at 22:16

The mod_wsgi binary is compiled for a specific Python version. You cannot force a version of mod_wsgi compiled for Python 2.7 to use a Python 3.4 installation.

My understanding is that Ubuntu supplies both Python 2 and Python 3 variants of mod_wsgi.

You therefore need to uninstall the one for Python 2 and install the alternate one for Python 3.

If they don't have a Python 3.4 variant, you would need to uninstall the Ubuntu package for mod_wsgi and build mod_wsgi from source code against Python 3.4 and install it yourself.

Alternatively consider using mod_wsgi-express and run it out of your virtual environment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.