为什么需要设置 WORKON_HOME 环境变量? [英] Why do you need to set the WORKON_HOME environment variable?
问题描述
我有一段时间没有使用我的 python/虚拟环境,但我也安装了虚拟环境包装器.
I haven't used my python/virtual environments in a while, but I do have virtualenvironment wrapper installed also.
我的问题是,在文档页面中它说要这样做:
My question is, in the doc page it says to do this:
export WORKON_HOME=~/Envs
$ mkdir -p $WORKON_HOME
$ source /usr/local/bin/virtualenvwrapper.sh
$ mkvirtualenv env1
我只是在提示下这样做:
I simply did this at my prompt:
source /usr/local/bin/virutalenvwrapper.sh
现在我可以通过以下方式列出和选择环境:
And now I can list and select an environment by doing:
>workon
>workon envtest1
我的问题是,既然这对我有用,我很困惑为什么我应该创建一个环境变量 WORKON_HOME 并将其指向 ~/Envs 文件夹?那有什么作用,为什么我的没有它就可以正常工作?我也没有那个/Envs 文件夹(我知道是脚本创建的).
My question is, since this works for me, I'm confused why I should be creating an environmental variable WORKON_HOME and point it to the ~/Envs folder? What does that do and how come mine works fine w/o it? I don't have that /Envs folder either (I know the script creates it).
参考:http://virtualenvwrapper.readthedocs.org/en/latest/
推荐答案
如果 WORKON_HOME
未设置,您的默认 virtualenv 文件夹将设置为 ~/.virtualenvs
(参见 virtualenvwrapper">virtualenvwrapper">virtualenvwrapper.>)
If WORKON_HOME
is not set, your default virtualenv folder will be set to ~/.virtualenvs
(see virtualenvwrapper.sh l.118)
您还将使用 WORKON_HOME
指定要使用哪个文件夹的 pip
(export PIP_VIRTUALENV_BASE=$WORKON_HOME
)
You will also use WORKON_HOME
to specify to pip
which folder to use (export PIP_VIRTUALENV_BASE=$WORKON_HOME
)
来源:virtualenvwrapper.readthedocs.org : 依赖于 pip 的 virtualenv 支持
这篇关于为什么需要设置 WORKON_HOME 环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!