[英]How do you tell django which python version to use?
The default version of python on centos is 2.6 and I am using a feature in my django app that requires 2.7 . 在centos上python的默认版本是2.6,我在django应用中使用了需要2.7的功能。 Where would I specify which version to use?
我在哪里指定使用哪个版本?
The python path for 2.7 is at /usr/local/bin/python2.7 2.7的python路径位于/usr/local/bin/python2.7
The webserver I am using is apache. 我正在使用的Web服务器是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版本:
virtualenv --python=python2.7 <your_venv_name>
For mod_wsgi
, have a look in the apache modules directory. 对于
mod_wsgi
,请查看apache modules目录。 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): 我没有使用centos的经验,但是在Debian上的
/usr/lib/apache2/modules
,可以通过修改mod_wsgi.so
symlink(在debian oldstable上)来选择python版本:
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
) (作为参考:对于python3,您需要安装一个单独的软件包
libapache2-mod-wsgi-py3
)
I imagine centos has something similar. 我想象centos有类似的东西。 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. 如果没有,则需要找到针对python 2.7构建的
mod_wsgi
软件包,或者针对正确的python版本从源代码重建mod_wsgi
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.