django - Apache mod_wsgi uses different version of python than which mentioned in python-path and WSGIPythonHome -
there lot of similar questions, have gone through , none of fixed issue. have configured httpd in centos 6 run django mod_wsgi. since dist python version 2.6, compiled , installed python2.7 (ucs2, shared-lib). created virtulenv 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 server thrown 500 error , using different version of python more details added couple of lines in wsgi.py below
import sys print sys.version print sys.executable print sys.maxunicode print sys.prefix after restarting server got below details 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 loaded 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] 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] 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] _struct import * [error] [client 10.3.35.113] importerror: /usr/local/lib/python2.7/lib-dynload/_struct.so: undefined symbol: pyunicodeucs2_asencodedstring so logs using /usr/bin/python , shows 2.7 when run
# /usr/bin/python python 2.6.6 (r266:84292, jul 23 2015, 15:22:56) my questions are:
- why not using python given in wsgi config?
- if using /usr/bin/python, why showing 2.7?
- how can server running python 2.7?
1) check
site.addsitedir('/var/www/uatenv/lib/python2.7/site-packages') line exists or doesn't point path in /var/www/uatenv/my_app/core/wsgi.py file.
2) /usr/bin/python link file
3)
sudo mv /usr/bin/python /root/python.backup this makes backup of python file under root directory.then :
sudo ln -s /usr/bin/python2.7 /usr/bin/python
Comments
Post a Comment