0
votes

I'm trying to deploy a Python app via mod_wsgi in Apache httpd, running into a strange error. I'm using my firm's custom python package (2.7), besides this there is another Python intsallation, shipped with the OS (different version, 2.6 something). The issue is, when I define the WSGIPythonHome and WSGIPythonPath variables in my httpd conf, I'm flooded with "ImportError: no module named site" errors in the error_log. Looking at other answers, defining those variables would be the solution for such errors. If I switch user to the apache user, with being the PYTHONPATH and PYTHONHOME env variables set, when I try to start Python 2.7, I'm getting the same error.

After unsetting the variables, Python is able to start normally. So I've tried removing the WSGIPythonHome and WSGIPythonPath from the httpd conf, but in that case, nothing happens, the wsgi script is not executed, as nothing is pointing Apache to my python executable. The mod_wsgi.so has been installed with pip, and loaded from the same path as my PYTHONPATH would be for 2.7

1

1 Answers

0
votes

It is likely that mod_wsgi Apache is using is compiled for Python 2.6. You cannot make mod_wsgi compiled for Python 2.6, work with a Python 2.7 installation or virtual environment.

You should verify what Python version mod_wsgi was compiled for by running ldd on the mod_wsgi.so binary. Don't assume it is using the pip installed version, you may still have system mod_wsgi installed.

If it is the system mod_wsgi package and it is compiled for Python 2.6, you will need to uninstall it.