[英]How can I change the Python that my Django project is using?
I have 2 versions installed in my server. 我的服务器中安装了2个版本。 I used virtualenv to install Python 2.7. 我使用virtualenv来安装Python 2.7。
I am using WSGI to deploy my project. 我正在使用WSGI来部署我的项目。
WSGIPythonPath /home/ENV/lib/python2.7/site-packages
WSGIScriptAlias / /var/www/html/my_project/wsgi.py
My http.conf is like that. 我的http.conf就是这样的。
python -V gives python -V给出
Python 2.7.3 Python 2.7.3
But in my projects Debug window, it says Django is using 2.6.8. 但在我的项目Debug窗口中,它表示Django正在使用2.6.8。 Where am I wrong? 我哪里错了?
UPDATE: Here is my wsgi file 更新:这是我的wsgi文件
import os
import sys
sys.path.append('/var/www/html')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
Python Version: 2.6.8 Python Path: Python版本:2.6.8 Python路径:
['/home/ENV/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg', '/home/ENV/lib/python2.7/site-packages/pip-1.1-py2.7.egg', '/home/ENV/lib/python2.7/site-packages/Django-1.4-py2.7.egg', '/home/ENV/lib/python2.7/site-packages', '/usr/lib/python2.6/site-packages/pip-1.1-py2.6.egg', '/usr/lib/python2.6/site-packages/django_transmeta-0.6.7-py2.6.egg', '/usr/lib/python2.6/site-packages/ipython-0.13-py2.6.egg', '/usr/lib/python2.6/site-packages/virtualenv-1.7.2-py2.6.egg', '/usr/lib64/python26.zip', '/usr/lib64/python2.6', '/usr/lib64/python2.6/plat-linux2', '/usr/lib64/python2.6/lib-tk', '/usr/lib64/python2.6/lib-old', '/usr/lib64/python2.6/lib-dynload', '/usr/lib64/python2.6/site-packages', '/usr/lib64/python2.6/site-packages/gtk-2.0', '/usr/lib/python2.6/site-packages', '/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info', '/var/www/html'] ['/home/ENV/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg','/home/ENV/lib/python2.7/site-packages/pip-1.1-py2 .7.egg','/ home / ENV / lib / python2.7 / site-package /Django-1.4-py2.7.egg','/ home / enV / lib / python2.7 / site -packages', '/usr/lib/python2.6/site-packages/pip-1.1-py2.6.egg','/usr/lib/python2.6/site-packages/django_transmeta-0.6.7-py2.6.egg ','/ usr / lib / python2.6 / site-package / ipython-0.13-py2.6.egg','/ usr / lib / python2.6 / site-packages / virtualenv-1.7.2-py2.6 .egg','/ usr / lib64 / python26.zip','/ usr / lib64 / python2.6','/ usr / lib64 / python2.6 / plat-linux2','/ usr / lib64 / python2.6 / lib-tk','/ usr / lib64 / python2.6 / lib-old','/ usr / lib64 / python2.6 / lib-dynload','/ usr / lib64 / python2.6 / site-packages' ,'/ usr / lib64 / python2.6 / site-packages / gtk-2.0','/ usr / lib / python2.6 / site-package','/ usr / lib / python2.6 / site-package / setupupols -0.6c11-py2.6.egg-info','/ var / www / html']
In my error_log of httpd: 在我的httpd的error_log中:
[Tue Jul 10 20:51:29 2012] [error] python_init: Python version mismatch, expected '2.6.7', found '2.6.8'. [Tue Jul 10 20:51:29 2012] [错误] python_init:Python版本不匹配,预计'2.6.7',找到'2.6.8'。 [Tue Jul 10 20:51:29 2012] [error] python_init: Python executable found '/usr/bin/python'. [Tue Jul 10 20:51:29 2012] [错误] python_init:Python可执行文件找到'/ usr / bin / python'。 [Tue Jul 10 20:51:29 2012] [error] python_init: Python path being used '/usr/lib64/python26.zip:/usr/lib64/python2.6/:/usr/lib64/python2.6/plat-linux2:/usr/lib64/python2.6/lib-tk:/usr/lib64/python2.6/lib-old:/usr/lib64/python2.6/lib-dynload'. [Tue Jul 10 20:51:29 2012] [error] python_init:正在使用的Python路径'/usr/lib64/python26.zip:/usr/lib64/python2.6/:/usr/lib64/python2.6/plat -linux2:/usr/lib64/python2.6/lib-tk:/usr/lib64/python2.6/lib-old:/usr/lib64/python2.6/lib-dynload”。
If I understand the question correctly, you are trying to configure the application's wsgi script to use a specific virtualenv. 如果我正确理解了这个问题,那么您正在尝试将应用程序的wsgi脚本配置为使用特定的virtualenv。
If that is the case check out modwsgi's docs: http://code.google.com/p/modwsgi/wiki/VirtualEnvironments 如果是这种情况,请查看modwsgi的文档: http : //code.google.com/p/modwsgi/wiki/VirtualEnvironments
I'd try to TLDR it for you, but its very well written at that link and I wouldn't be able to do it justice. 我会尝试为你做TLDR,但它在那个链接上写得非常好,我无法做到公道。
The mod_wsgi module must be compiled for the specific Python major/minor version you want to use. 必须针对要使用的特定Python主要/次要版本编译mod_wsgi模块。 You cannnot use WSGIPythonHome to force a mod_wsgi compiled against Python 2.6 to use a Python virtual environment constructed using Python 2.7. 您无法使用WSGIPythonHome强制针对Python 2.6编译的mod_wsgi使用使用Python 2.7构建的Python虚拟环境。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.