SyntaxError与VirtualEnv + mod-wsgi在Django [英] SyntaxError with VirtualEnv + mod-wsgi in Django
问题描述
我在使用 VirtualEnv
在我的生产 Ubuntu 13.04
服务器与 mod- wsgi
。
I am having trouble using VirtualEnv
on my production Ubuntu 13.04
server with mod-wsgi
.
有人可以指出问题可能是什么?
Would someone be able to point out what the issue may be?
这是我得到以下语法错误的追溯:
Here is the traceback that I am getting the below syntax error:
[Mon Jul 14 14:37:09 2014] [error] [client 70.180.246.22] mod_wsgi (pid=14292): Target WSGI script '/home/aaron/public_html/flapsta.com/flapsta/flapsta/flapsta.wsgi' cannot be loaded as Python module.
[Mon Jul 14 14:37:09 2014] [error] [client 70.180.246.22] mod_wsgi (pid=14292): Exception occurred processing WSGI script '/home/aaron/public_html/flapsta.com/flapsta/flapsta/flapsta.wsgi'.
[Mon Jul 14 14:37:09 2014] [error] [client 70.180.246.22] Traceback (most recent call last):
[Mon Jul 14 14:37:09 2014] [error] [client 70.180.246.22] File "/home/aaron/public_html/flapsta.com/flapsta/flapsta/flapsta.wsgi", line 16, in <module>
[Mon Jul 14 14:37:09 2014] [error] [client 70.180.246.22] execfile(activate_env, dict(__file__=activate_env))
[Mon Jul 14 14:37:09 2014] [error] [client 70.180.246.22] File "/home/.virtualenvs/flapsta/bin/activate", line 4
[Mon Jul 14 14:37:09 2014] [error] [client 70.180.246.22] deactivate () {
[Mon Jul 14 14:37:09 2014] [error] [client 70.180.246.22] ^
[Mon Jul 14 14:37:09 2014] [error] [client 70.180.246.22] SyntaxError: invalid syntax
我的flapsta.wsgi文件设置如下: p>
I have my flapsta.wsgi file set up like so:
import os
import sys
import site
# Add the site-packages of the chosen virtualenv to work with
site.addsitedir('/home/.virtualenvs/flapsta/lib/python2.7/site-packages')
# Add the app directories to the PYTHONPATH
sys.path.append('/home/aaron/public_html/flapsta.com')
sys.path.append('/home/aaron/public_html/flapsta.com/flapsta')
os.environ['DJANGO_SETTINGS_MODULE'] = 'flapsta.settings'
# Activate the virtualenv
activate_env=os.path.expanduser('/home/.virtualenvs/flapsta/bin/activate')
execfile(activate_env, dict(__file__=activate_env))
import django.core.handlers.wsgi
_application = django.core.handlers.wsgi.WSGIHandler()
def application(environ, start_response):
# DB
# .... envirtonment variables ....
return _application(environ, start_response)
当我注释掉这行:
execfile(activate_env, dict(__file__=activate_env))
它不再激活 virtualenv
,我可以加载网站的罚款,但我不能使用 virtualenv
显然要托管具有不同依赖关系的多个站点。
It no longer activates the virtualenv
and I can load the site fine, but I can't use virtualenv
obviously to host multiple sites with different dependencies.
这是一个已知的问题,或者我在某处可以帮助p oint out?
Is this a known issue, or am I missing a piece of configuration somewhere that someone could help point out?
我正在运行:
Django 1.5.4
viritualenv 1.11.1
Apache2.2
Ubuntu 13.04
Python 2.7.4
提前感谢
推荐答案
您正在尝试在Python中执行bash激活脚本。您应该执行 activate_this.py
Python脚本。
You're trying to execute the bash activate script in Python. You should be executing the activate_this.py
Python script.
这篇关于SyntaxError与VirtualEnv + mod-wsgi在Django的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!