0

我仍然无法最终理解 apache 如何理解它现在应该运行哪个版本的 python。

在 virtualenv 我只安装 python3.2 ,然后我把这样的代码放在 wsgi 包装器上:

# -*- coding: utf-8 -*-
#!/virtualenvs/simpleboard/bin/python

import os, sys, site

my_virtualenv_path = "/virtualenvs/simpleboard/lib/python3.2/site-packages/"
# Add it to your PYTHONPATH


sys.path.insert(0, my_virtualenv_path)
site.addsitedir(my_virtualenv_path)

sys.path.insert(0, os.path.dirname(__file__))
sys.path.insert(0, '/www/django/simpleboard/simpleboard')
sys.path.insert(0, '/www/django/simpleboard')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "simpleboard.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

最后我在我的类代码的头部添加了这个标签,但 apache 仍然运行 2.7

Exception Location:     /www/django/simpleboard/account/views.py in rescale, line 386
Python Executable:  /usr/bin/python
Python Version:     2.7.3
Python Path:    
['../..',
 '/www/django/simpleboard',
 '/www/django/simpleboard/simpleboard',
 '/www/django/simpleboard/simpleboard',
 '/virtualenvs/simpleboard/lib/python3.2/site-packages/',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-linux2',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages']

Server time:    Wed, 11 Sep 2013 19:43:21 +0400

如您所见,它运行 2.7 版本并因此出现回溯错误

4

1 回答 1

1

您可以使用 uwsgi ( http://projects.unbit.it/uwsgi/wiki/VirtualEnv ) 的 virtualenv 支持。在 uwsgi 初始化脚本中将“H /virtualenvs/simpleboard”添加到 uwsgi 命令。

于 2013-09-11T17:07:38.943 回答