Webfaction - Installing virtualenv & virtualenvwrapper
I can’t ever imagine how I managed without virtualenv, I really can’t. Having each django project or python mind-fart in it’s own little sandbox is brilliant because it doesn’t matter what version of anything you have, there’ll be no “inter-project-versioning-clashes”. However, before you can enjoy the good times there are a few things you’ll need to do first. Don’t worry though because you only have to do this once.
First things first, open up a terminal.
Installing pip is easy, but note that we’re going to use sudo because we want pip installed system wide.
sudo easy_install pip
Let’s check the install.
It should come back with something like this
Usage: pip COMMAND [OPTIONS] pip: error: You must give a command (use "pip help" to see a list of commands)
Very good, let’s install virtualenv.
We can now install virtualenv, again we’re doing this system wide.
sudo pip install virtualenv
Let’s check that
And it should come back with a lot of output. It’ll start something like this, but I’ve omitted most of it.
virtualenv You must provide a DEST_DIR ...
Now install virtualenvwrapper, again this is systemwide.
sudo pip install virtualenvwrapper
Here’s where you have to do something a little different. In your home directory make a folder called .virtualenvs, If you don’t do this virtualenvwrapper will whinge at you
cd $HOME mkdir .virtualenvs
You now need to have your shell loadup the virtualenvwrapper.sh script. To do this we’re going to add a line into your .bash_login file. I like to use vi for things like this but you could use anything you want to edit the file. Here’s how to open it up in vi
Now add the following line ( remember to press ‘i’ to get into insert mode) into the bottom of your file. This will load up the virtualenvwrapper.sh script into your terminal windows. This will give you the power of virtualenvwrapper. Once you’ve added the line you should write and quit out of vi. ( escape, colon, w, q, return)
Now close your terminal window/tab and open up a new one. (There are other ways to reload your .bash_login, but this one is the quickest for me) Because is the first time that the virtualenvwrapper script has ran it may output some stuff.
Now lets check it. You should be able to just type, m,k,v and then tab and it should autocomplete.
It should spit some stuff back at you.
If it does then you’ve cracked it. Welcome to good times.
From here on out the documentation for virtualenvwrapper will be your best friend.