Target WSGI script cannot be loaded as Python module
Solution 1:
For me the problem was wsgi python version mismatch. I was using python 3, so:
$ sudo apt-get remove libapache2-mod-python libapache2-mod-wsgi
$ sudo apt-get install libapache2-mod-wsgi-py3
Warning from @alxs before you copy/paste these commands:
If there are python 2 projects running on the server that use wsgi and apache, the above commands will effectively shut them down.
Solution 2:
For me the issue was that the WSGI script wasn't executable.
sudo chmod a+x django.wsgi
or just
sudo chmod u+x django.wsgi
so long as you have the correct owner
Solution 3:
I had a similar problem with this error message in the logs:
Target WSGI script '/home/web2py/wsgihandler.py' cannot be loaded as Python module.
The solution was the deletion of an incorrect WSGIPythonHome directive (pointing to the application directory) from /etc/httpd/conf.d/wsgi.conf
I'm on RedHat using CentOS repositories.
Recommend following Graham Dumpleton's installation/configuration instructions. Testing configuration against the helloworld application showed me that mod_wsgi
was working and the configuration was at fault.
However, the error message gave little clue as to what was wrong.
Solution 4:
I had the same problem and at first I didn't realise I could scroll further down and see the actual error message. In my case, it was an import error:
ImportError: No module named bootstrap3
After installing it via pip (pip install django-bootstrap3), I restarted Apache and it worked.