【发布时间】:2015-03-08 09:32:25
【问题描述】:
我正在尝试按照本指南 http://thecodeship.com/deployment/deploy-django-apache-virtualenv-and-mod_wsgi/ 在 apache 上设置虚拟环境。我在 index.wsgi 的最后阶段遇到了问题。这是我的 index.wsgi 的内容:
import os
import sys
import site
# Add the site-packages of the chosen virtualenv to work with
site.addsitedir('~/.virtualenvs/splinter/lib/python3.2/site-packages')
# Add the app's directory to the PYTHONPATH
sys.path.append('/var/www/splinter')
sys.path.append('/var/www/splinter/splinter')
os.environ['DJANGO_SETTINGS_MODULE'] = 'splinter.settings'
# Activate your virtual env
activate_env=os.path.expanduser("~/.virtualenvs/splinter/bin/activate_this.py")
execfile(activate_env, dict(__file__=activate_env))
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
错误日志指出:
No such file or directory: '/var/www/.virtualenvs/splinter/bin/activate_this.py'
它在路径的前面添加了“var/www/”,所以我尝试删除 os.path.expanduser,即使现在路径正确,并且文件确实存在,我仍然得到同样的错误:
No such file or directory: '~/.virtualenvs/splinter/bin/activate_this.py'
请帮我解决这个问题,我感觉很亲密!
【问题讨论】:
标签: python django python-3.x