I want to use Django and create virtual environments. I don’t quite understand the initializing steps documentation on the virtualenvwrapper website. I’ve installed virtualenvwrapper in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages. I’ve already installed XCode, Homebrew and Posgres as well.
The documentation tells me to:
$ export WORKON_HOME=~/Envs
$ mkdir -p $WORKON_HOME
$ source /usr/local/bin/virtualenvwrapper.sh
$ mkvirtualenv env1`
I’m especially confused about the first line. Is it telling me that I need to create a project folder named ‘WORKON_HOME’ and export it into another folder called ‘Envs’? (I’ve searched for both folders on my mac but didn’t find them). And then in the second line I make another directory ‘WORKON_HOME’?
If you have suggestions or links to better explanations/tutorials, I would greatly appreciate it. Thanks.
Place this 3 lines in your
~/.bash_profilefile:-The
$HOMEenvironment variable points to your user’s home. Also known as the tilda “~”, i.e./Users/your_osx_username/.WORKON_HOMEis the new environment variable that you are assigning by using theexportcall in your~/.bash_profilefile. This is where all your newly created virtualenv directories will be kept.PROJECT_HOMEis where you normally place all your custom project directories manually. Nothing to do with your virtualenvs per say but just an easy reference point for you to cd to using thecd $PROJECT_HOMEsyntax.which virtualenvwrapper.shpoints to the location where the bash scriptvirtualenvwrapper.shis located and hence when you source it, the functions in that bash script becomes available for yourmkvirtualenvcalls.Whenever you open a “new shell” (new tab, close your current tab after you first update your
~/.bash_profilefile), all these environment variables and bash functions will be thus available in your shell.When we create a new virtualenv using the
mkvirtualenv -p python2.7 --distribute my_new_virtualenv_1, what actually happens is that a new directory calledmy_new_virtualenv_1containing a symlink to your global python2.7 is being created and new python site-packages sub-directory are created in your~/.virtualenvs/directory. Reference:-So if you do
You will see this directory structure in it.
Note of course that you are using
Envsand I am using.virtualenvsto act as the virtual env holding directory.