[英]python3 virtualenv no such file or directory
我正在尝试遵循本指南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'
请帮我解决这个问题,我感觉好近!
另一种可能性是使用您的用户名来扩展用户:
activate_env = os.path.expanduser(
"~chris/.virtualenvs/splinter/bin/activate_this.py")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.