This repository provides the necessary files to provision a virtual machine with a python virtual environment with numpy, scipy, matplotlib, ipython and the required packages (jinja2, pyzmq, tornado) to run the ipython notebook.
At the time of this writing the box used is the official Ubuntu Server 14.04 LTS (Trusty Tahr) build as found at Vagrant Cloud at https://vagrantcloud.com/ubuntu/trusty64.
You should have recent versions of the following installed:
and the following vagrant plugins:
$ vagrant plugin install vagrant-cachier vagrant-vbguest
Run:
$ vagrant up
NOTE: Especially if it is the first time you build the machine, it'll take a while. (Perhaps in between 10 to 15 minutes plus the time to download the ubuntu image.)
Connect:
$ vagrant ssh
The box is provisioned to have a pre-built python virtual environment, named
env
under /home/vagrant
.
Active it
vagrant@(...)~$ source ~/env/bin/activate
The provisioning phase should also install the python packages listed under
~/requirements.txt
and scipy
. You can run the small script
~/lab/versions.py
to check that everything is there.
$ python ~/lab/versions.py
IPython: 2.4.1
jinja2: 2.7.3
matplotlib: 1.4.2
numpy: 1.9.1
scipy: 0.15.1
tornado: 4.1
zmq: 14.5.0
Before running the notebook, check the ip address (<box_ip>
) of the virtual
machine. You can run ifconfig
to do so.
In the virtual environment run:
(env)vagrant@(...)~$ ipython notebook --ip=0.0.0.0 --no-browser
You should then be able to access the notebook from the host machine at
http://<box_ip>:8888
Using an automatic vagrant bash completion, may be helpful to speed up your work when using vagrant.
The first time you run vagrant up
the box will be provisioned, but
afterwards it will not as this takes more time, and may not be needed. You can
instruct vagrant to provision the box like so:
$ vagrant up --provision
If the box is already running then you can use the reload
command like so:
$ vagrant reload --provision
You can execute the salt states manually within the virtual machine, using the salt-call command:
vagrant@(...)~$ salt-call --local state.highstate -l debug
This will "re-provision" the machine, and is usually faster than getting out of
the virtual machine, and invoking vagrant reload --provision
.
It is useful to use this approach when troubleshooting the provisioning
phase, and trying different configurations to fix the issue. That is, you can
modify one or more salt states, and run salt-call
to see the effect.