There are a lot of similar questions, but i have gone through all and none of that fixed my issue. I have configured httpd in Centos 6 to run django with mod_wsgi. Since dist python was version 2.6, i compiled and installed python2.7 (UCS2, shared-lib). Created a virtulenv with virtualenv -p /usr/local/bin/python2.7 under /var/www/uatenv
<VirtualHost *:8080>
Alias /static/ /var/www/uatenv/my_app/static/
WSGIDaemonProcess rbuat python-path=/var/www/my_app/core:/var/www/uatenv/lib/python2.7/site-packages
WSGIProcessGroup rbuat
WSGIScriptAlias / /var/www/uatenv/my_app/core/wsgi.py
</VirtualHost>
But it the server thrown 500 error and it was using a different version of python
To get more details i added a couple of lines in wsgi.py as below
import sys
print sys.version
print sys.executable
print sys.maxunicode
print sys.prefix
After restarting the server got the below details from logs
[notice] Apache/2.2.15 (Unix) DAV/2 mod_wsgi/4.4.21 Python/2.7.10 mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations
[error] 2.7.10 (default, Dec 29 2015, 07:15:09)
[error] [GCC 4.4.7 20120313 (Red Hat 4.4.7-16)]
[error] /usr/bin/python
[error] 1114111
[error] /usr/local
[error] [client 10.3.35.113] mod_wsgi (pid=7118): Target WSGI script '/var/www/uatenv/my_app/core/wsgi.py' cannot be loaded as Python module.
[error] [client 10.3.35.113] mod_wsgi (pid=7118): Exception occurred processing WSGI script '/var/www/uatenv/my_app/core/wsgi.py'.
[error] [client 10.3.35.113] Traceback (most recent call last):
[error] [client 10.3.35.113] File "/var/www/uatenv/my_app/core/wsgi.py", line 17, in <module>
[error] [client 10.3.35.113] from django.core.wsgi import get_wsgi_application
[error] [client 10.3.35.113] File "/var/www/uatenv/lib/python2.7/site-packages/django/__init__.py", line 1, in <module>
[error] [client 10.3.35.113] from django.utils.version import get_version
[error] [client 10.3.35.113] File "/var/www/uatenv/lib/python2.7/site-packages/django/utils/version.py", line 5, in <module>
[error] [client 10.3.35.113] import subprocess
[error] [client 10.3.35.113] File "/usr/local/lib/python2.7/subprocess.py", line 430, in <module>
[error] [client 10.3.35.113] import pickle
[error] [client 10.3.35.113] File "/usr/local/lib/python2.7/pickle.py", line 34, in <module>
[error] [client 10.3.35.113] import struct
[error] [client 10.3.35.113] File "/usr/local/lib/python2.7/struct.py", line 1, in <module>
[error] [client 10.3.35.113] from _struct import *
[error] [client 10.3.35.113] ImportError: /usr/local/lib/python2.7/lib-dynload/_struct.so: undefined symbol: PyUnicodeUCS2_AsEncodedString
So from the logs it is using /usr/bin/python and shows 2.7 but when i run
# /usr/bin/python
Python 2.6.6 (r266:84292, Jul 23 2015, 15:22:56)
My Questions are:
- Why is it not using the python i given in wsgi config?
- If it is using /usr/bin/python, then why is it showing as 2.7?
- How can i get my server running with python 2.7?