Dmitry Leskov

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.

  1. 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.
  2. In the meantime, download the Linux version of the Google App Engine SDK for Python:

    wget -c

    (look up the current URL on the SDK download page)

  3. Fetch the latest version of OPT from GitHub:

    wget -c -O
  4. It turned out that Ubuntu 12.04 Server has Python installed even in the minimal configuration. I had to install unzip though:

    sudo apt-get install unzip
  5. 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 ~/
    sudo unzip ~/
  6. (optional) Rename the OPT directory:

    sudo mv pgbovine-OnlinePythonTutor-c4880ea online-python-tutor
  7. Try running OPT:

    sudo /opt/google_appengine/ \
      -a \
      -p 80 \
      --skip_sdk_update_check \

    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.

  8. 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-C to shutdown the development server.

  9. Finally, make OPT start automatically on boot. On Ubuntu and other Upstart-enabled systems, add a .conf file to /etc/init:

    sudoedit /etc/init/pythontutor.conf

    with the following content (change installation directories if necessary):

    start on runlevel [2345]
    stop on runlevel [!2345]
    expect fork
    exec /opt/google_appengine/ \
      --skip_sdk_update_check  \
      -a -p 80 \
      /opt/online-python-tutor/v3 &
  10. Start the pythontutor job:

    sudo start pythontutor

    If this time you cannot connect to OPT from your browser, look for clues in /var/log/upstart/pythontutor.

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.

« | »


* Copy This Password *

* Type Or Paste Password Here *