Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do you need to set the WORKON_HOME environment variable?

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

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).

Reference: http://virtualenvwrapper.readthedocs.org/en/latest/

like image 250
Blankman Avatar asked Dec 09 '12 13:12

Blankman


2 Answers

If WORKON_HOME is not set, your default virtualenv folder will be set to ~/.virtualenvs
(see virtualenvwrapper.sh l.118)

You will also use WORKON_HOME to specify to pip which folder to use (export PIP_VIRTUALENV_BASE=$WORKON_HOME)

source : virtualenvwrapper.readthedocs.org : Tying to pip’s virtualenv support

like image 185
rxdazn Avatar answered Oct 21 '22 01:10

rxdazn


I'm confused why I should be creating an environmental variable WORKON_HOME and point it to the ~/Envs folder?

It's optional. You're confused (like I was) because the documentation is confusing.

What does that do and how come mine works fine w/o it?

It tells virtualenvwrapper which folder to search for Python environments. The command workon searches the path WORKON_HOME if it's defined, or ~/.virtualenvs if it's not, which is why it works by default.

A use case for defining a different WORKON_HOME directory would be if you have different environments you want to available to virtualenvwrapper. For example, if you save virtual env backups to a different folder or have multiple users who want to maintain their own environments.

like image 2
cs01 Avatar answered Oct 21 '22 01:10

cs01