Much of the material in this document is taken from Appendix H.1 in the book A Primer on Scientific Programming with Python, 4th edition, by the same author, published by Springer, 2014.
A virtual machine allows you to run another complete computer system in a separate window. For Mac users, I recommend VMWare Fusion over VirtualBox for running a Linux (or Windows) virtual machine. (VMWare Fusion's hardware integration seems superior to that of VirtualBox.) VMWare Fusion is commercial software, but there is a free trial version you can start with. Alternatively, you can use the simpler VMWare Player, which is free for personal use.
The following recipe will install a Ubuntu virtual machine under VMWare Fusion.
ubuntu-14.04-amd64-vmware.ova
(6.7 Gb!).ubuntu-14.04-amd64-vmware.ova
file you downloaded.Ctrl+space
or Ctrl+backslash
, in the
Switch to next source using field. Then you can use the shortcut
to quickly switch keyboard.gnome-terminal
, right-click
its new icon in the left pane and choose Lock to Launcher
such
that you always have the terminal easily accessible when you log in.
The gnome-terminal
can have multiple tabs (Ctrl+shift+t
to make
a new tab).If you have a minimalistic Ubuntu machine downloaded from the Ubuntu site, you need to install additional software for scientific computing with Python:
Terminal> sudo apt-get install python-setuptools python-pip mercurial
Terminal> sudo pip install numpy sympy scipy nose pytest
Terminal> sudo apt-get install python-matplotlib spyder
Terminal> sudo pip install ipython --upgrade
Terminal> sudo pip install tornado --upgrade
Terminal> sudo pip install pyzmq --upgrade
Terminal> sudo pip install -e \
git+https://github.com/hplgit/scitools.git#egg=scitools
The Ubuntu machine can see the files on your host system if you
download VMWare Tools. Go to the Virtual Machine pull-down menu in
VMWare Fusion and choose Install VMWare Tools. A tarfile is
downloaded. Click on it and it will open a folder vmware-tools-distrib
,
normally in your home folder. Move to the new folder and
run sudo perl vmware-install.pl
.
You can go with the default answers to all the questions.
On a Mac, you must open Virtual Machine - Settings... and choose
Sharing to bring up a dialog where you can add the folders you want
to be visible in Ubuntu. Just choose your home folder. Then turn on
the file sharing button (or turn off and on again). Go to Ubuntu and
check if you can see all your host system's files in /mnt/hgfs/
.
If you later detect that /mnt/hgfs/
folder has become empty,
VMWare Tools must be reinstalled by first turning shared folders
off, and then running
Terminal> sudo /usr/bin/vmware-config-tools.pl
Occasionally it is necessary to do a full reinstall by
sudo perl vmware-install.pl
as above.
Documents/Virtual Machines/Ubuntu 64-bit
.
Backing up the Ubuntu machine means backing up this folder.
However, if you use tools like Time Machine and work in Ubuntu during
backup, the copy of the state of the Ubuntu machine is likely to
be corrupt. You are therefore strongly recommended to shut down the
virtual machine prior to running Time Machine or simply copying the
folder with the virtual machine to some backup disk.
If something happens to your virtual machine, it is usually a straightforward task to make a new machine and import data and software automatically from the previous machine.