문제

The default version of python on centos is 2.6 and I am using a feature in my django app that requires 2.7 . Where would I specify which version to use?

The python path for 2.7 is at /usr/local/bin/python2.7

The webserver I am using is apache. I have tried a few different things but have not had much luck. Any ideas?

도움이 되었습니까?

해결책

If you are using a virtualenv (hint: you should), you can specify the python version when creating the environment:

virtualenv --python=python2.7 <your_venv_name>

For mod_wsgi, have a look in the apache modules directory. I have no experience with centos, but on Debian, in /usr/lib/apache2/modules, you can choose the python version by modifying the mod_wsgi.so symlink (this is on debian oldstable):

lrwxrwxrwx 1 root root     15 Feb 10  2011 mod_wsgi.so -> mod_wsgi.so-2.5
-rw-r--r-- 1 root root 151648 Sep 26  2010 mod_wsgi.so-2.5
-rw-r--r-- 1 root root 151680 Sep 26  2010 mod_wsgi.so-2.6

(For reference: for python3, you need to install a separate package, libapache2-mod-wsgi-py3)

I imagine centos has something similar. If there isn't, you need to either find a mod_wsgi package built against python 2.7, or rebuild mod_wsgi from source against the right python version.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top