It's all started from installing new python version, 2.7.5. I get this error when WSGI runs my django's wsgi.py file:
[Tue Sep 03 23:25:42 2013] [error] [client XXX.XXX.XXX.XXX] mod_wsgi (pid=4710): Target WSGI script '/var/www/empirik/data/www/mysite.com/my_project/wsgi.py' cannot be loaded as Python module.
[Tue Sep 03 23:25:42 2013] [error] [client XXX.XXX.XXX.XXX] mod_wsgi (pid=4710): Exception occurred processing WSGI script '/var/www/empirik/data/www/mysite.com/my_project/wsgi.py'.
[Tue Sep 03 23:25:42 2013] [error] Traceback (most recent call last):
[Tue Sep 03 23:25:42 2013] [error] File "/var/www/empirik/data/www/mysite.com/my_project/wsgi.py", line 22, in ?
[Tue Sep 03 23:25:42 2013] [error] import os
[Tue Sep 03 23:25:42 2013] [error] File "/home/envs/my_project/lib/python2.7/os.py", line 49, in ?
[Tue Sep 03 23:25:42 2013] [error] import posixpath as path
[Tue Sep 03 23:25:42 2013] [error] File "/home/envs/my_project/lib/python2.7/posixpath.py", line 324
[Tue Sep 03 23:25:42 2013] [error] slash, dot = (u'/', u'.') if isinstance(path, _unicode) else ('/', '.')
[Tue Sep 03 23:25:42 2013] [error] ^
[Tue Sep 03 23:25:42 2013] [error] SyntaxError: invalid syntax
I use virtualenv and can't figure out why it happens. I have python 2.4.3 also installed on this machine but it's not even associated with "python" alias and there's definitely python 2.7.5 in my virtualenv.
UPDATE: Ok, I've raised exception in my wsgi.py to see sys.path which it uses and it's python2.4:
['/home/envs/my_env/lib/python24.zip', '/home/envs/my_env/lib/python2.4/', '/home/envs/my_env/lib/python2.4/plat-linux2', '/home/envs/my_env/lib/python2.4/lib-tk', '/home/envs/my_env/lib/python2.4/lib-dynload']
I don't understand why and how can I change it to python2.7.
It would appear your mod_wsgi is compiled for and uses Python 2.4. You cannot take a mod_wsgi built for one Python version and force it to use a runtime installation for a different version. Go check the state of the your mod_wsgi and what it is compiled for.