virtualenv
is a command-line utiltity that will allow you to encapsulate a python environment. Ubuntu calls the package that installs this utility "python-virtualenv". You can install it with $ sudo apt-get install python-virtualenv
.
$ cd ~
$ mkdir venv
$ virtualenv -p python3 --system-site-packages ~/venv
You'll need to 'activate' the virtualenv in order to make use of it. It will re-write your prompt to put the name of the virtualenv at the beginning.
$ source ~/venv/bin/activate
(venv)$
(venv)$ python --version
Python 3.4.0
(venv)$ pip --version
pip 7.1.0 from /home/halfak/venv/lib/python3.4/site-packages (python 3.4)
When you want to go back to the default python state, you'll need to deactivate the environment.
(venv)$ deactivate
$ python --version
Python 2.7.6
$ pip --version
pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7)
@halfak I've simplified a bit, you might want to pull this revision over to your gist.