Not logged in. Login

Working In a Virtual Machine

You can certainly do all of the work for this course by installing Python and some libraries on your own computer.

If nothing else works, or you want a very contained environment, you can create a virtual machine with everything you need. Your computer needs to be powerful enough to do whatever you are using it for (web browser, IDE, etc.), plus provide resources to a virtual machine: at least one core and 1 GB of memory.

Getting Started

  1. Install VirtualBox. You can do this in Windows, OSX, or Linux. In Ubuntu, this can by done by installing the package virtualbox (or virtualbox-qt if you want the GUI tools too).
  2. Install Vagrant. You can also do this in Windows, OSX, or Linux. In Ubuntu, install the vagrant package.
  3. Get the code for the VM recipe, either by checking out its Git repo or by downloading as a ZIP. [Checking out the Git repo might be more future-proof: if I have to update something, you can do a git pull and move on.]

If you try to start a virtual machine and it seems to hang, you can try starting a VM from the VirtualBox GUI: you can see error messages there. The most likely cause is not having processor virtualization extensions, either because they're off in your BIOS, or because you're trying to run a VM inside another VM.

You can start up the VM like this. It will take a while the first time, as it downloads and installs everything it needs.

vagrant up

If you'd like to share code from your computer into the VM, modify and uncomment the config.vm.synced_folder line in the Vagrantfile so you have something like this:

config.vm.synced_folder "../assignments", "/home/ubuntu/code"

Working With The VM

You can SSH in to the VM with the command:

vagrant ssh

Once you're in the VM, you can run basic Python commands as expected. For example,

pip3 install --user somelibrary
python3 code/some_program.py
ipython3

You can start a Jupyter Notebook, will want to access it from outside the VM. There's a script to do that included in the configuration:

jupyter-start

Outside the VM, go to the URL you're given with 0.0.0.0 replaced by localhost.

Updated Tue Aug. 29 2023, 10:33 by ggbaker.