Running Online Python Tutor in a Local Linux VM
Online Python Tutor (OPT) enables first-year CS students to watch the nicely visualized execution of their Python programs step-by-step.
A fresh edX student very much liked OPT but had two problems with its online nature: sometimes the OPT Web site was not responding, sometimes she had no Internet connection. Fortunately, OPT is open sourced on GitHub, so I was able to set it up on her Windows notebook as follows:
OPT runs on Google App Engine, but there is a local development server in the GAE SDK. I’ve set it up up on top of a small VirtualBox VM running Linux, so as to minimize interference with other software and simplify migration.
- Set up or clone a baseline Linux VM. I had a baseline Ubuntu 12.04 LTS disk image already, so just followed my own VirtualBox VM cloning recipe.
In the meantime, download the Linux version of the Google App Engine SDK for Python:
wget -c http://googleappengine.googlecode.com/files/google_appengine_1.7.3.zip
(look up the current URL on the SDK download page)
Fetch the latest version of OPT from GitHub:
wget -c -O online-python-tutor.zip https://github.com/pgbovine/OnlinePythonTutor/zipball/master
It turned out that Ubuntu 12.04 Server has Python installed even in the minimal configuration. I had to install
sudo apt-get install unzip
Unpack both packages. I have chosen to put them under
/opt(pun not intended – that is where FHS says you should put optional packages):
cd /opt sudo unzip ~/google_appengine_1.7.3.zip sudo unzip ~/online-python-tutor.zip
(optional) Rename the OPT directory:
sudo mv pgbovine-OnlinePythonTutor-c4880ea online-python-tutor
Try running OPT:
sudo /opt/google_appengine/dev_appserver.py \ -a 0.0.0.0 \ -p 80 \ --skip_sdk_update_check \ /opt/online-python-tutor/v3
There will be warnings about the unavailability of some APIs and such, but OPT apparently does not use those, so you may ingore the warnings.
Try connecting to the VM from your browser. You should see the main OPT screen and be able to use it:
Check that it works, then get back to the VM console/terminal and press
Ctrl-Cto shutdown the development server.
Finally, make OPT start automatically on boot. On Ubuntu and other Upstart-enabled systems, add a
with the following content (change installation directories if necessary):
start on runlevel  stop on runlevel [!2345] expect fork exec /opt/google_appengine/dev_appserver.py \ --skip_sdk_update_check \ -a 0.0.0.0 -p 80 \ /opt/online-python-tutor/v3 &
sudo start pythontutor
If this time you cannot connect to OPT from your browser, look for clues in
Now that everything is working, you may wish to reduce the amount of RAM allocated to the VM. 128MB is more than enough to run a copy of the OPT just for the user connecting from the host, but watch memory use if you install e.g. a shared copy for your class or something.