Saturday, August 1, 2015

Running VPython in a Browser with Anaconda, Jupyter, and iVisual

Installing iPython Jupyter and iVisual

In a previous post, I described how to install and run VPython using iPython Notebook. However, the previous instructions are now outdated due to the upgrade of Notebook to Jupyter. The instructions below are for Jupyter.

When you install Anaconda, it will automatically install iPython and Jupyter. The only additional package you need for running VPython programs in a notebook is iVisual. Here are the steps to install Anaconda and iVisual (more detailed instructions with screen captures are available):

  1. Install Anaconda. (
  2. From a command line, type:  pip install ivisual
  3. From a command line, type: ipython notebook
  4. The Jupyter home screen will open in your browser. The header of the page is shown below.

  5. Click the "New" menu and select "Python 2" as shown below.

    You will see a header for the new Jupyter notebook as shown below.

  6. Type the following program into the first cell.

from __future__ import division, print_function
from ivisual import *
#create scene
scene = canvas(title='3D scene')


You will see a VPython scene with a white sphere as shown below.

My Classical Mechanics class used iPython Notebook and iVisual for an entire semester, and it worked wonderfully. Here's a presentation I gave to Guilford College with a notebook.


  1. To display the scene while a simulation is running you can call the notebook display method and pass it the scene name. For instance.

    from ivisual import *

    scene2 = canvas(title="My 3D Scene")

    s = sphere()

    while True:
    # your code to simulate the objects in the scene

    By calling display(sceneX) prior to the simulation loop, the 3D scene will be visible during the simulation.

  2. Is there any way to interact with the display inside the Jupyter notebook?

  3. That is really good and informative post. Going to share it with my friends circle so tht they can get benefit out of it. Thank you for sharing it with us

  4. Amazing blog about the installation and runnig of Ipython and Ivisiual. This is a updated way of doing the process.