Mod_wsgi on Apache: Could not find platform independent libraries <prefixes>
I am trying to use Django with Apache, but when I try to start my WSGI application, I have the following error:
Could not find platform independent libraries <prefix> Could not find platform dependent libraries <exec_prefix> Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] ImportError: No module named site
I have this in include in my httpd.conf file:
WSGIPythonHome /home/ec2-user/anaconda WSGIScriptAlias / /home/ec2-user/test/wsgi.py WSGIPythonPath /home/ec2-user/test <Directory /home/ec2-user/test> <Files wsgi.py> Order deny,allow Allow from all </Files> </Directory>
And this is the content of my wsgi.py file:
import sys def application(environ, start_response): status = '200 OK' output = 'Hello World!' response_headers = [('Content-type', 'text/plain'), ('Content-Length', str(len(output)))] start_response(status, response_headers) print >> sys.stderr, 'sys.prefix = %s' % repr(sys.prefix) print >> sys.stderr, 'sys.path = %s' % repr(sys.path) return [output]
+4
source share
1 answer
I just had this problem. The problem is that I was using non-standard Python and PYTHONPATH was not installed properly.
I decided to change this statement in my file 10-wsgi.conf
:
LoadModule wsgi_module modules/mod_wsgi.so
On this:
LoadModule wsgi_module modules/mod_wsgi.so WSGIPythonHome /apps/intelpython3_2019.2/
Then, when wsgi starts, it starts using my Python version of Intel Anaconda, not the default Python.
In my case, I also needed to recompile mod_wsgi
to use Python3:
./configure --with-python=/apps/intelpython3_2019.2/bin/python3
I also needed to add the Python library to the system library:
$ cat /etc/ld.so.conf.d/python3.conf /apps/intelpython3_2019.2/lib
And of course:
# ldconfig
0
source share