If you're new to Python
and VPython: Introduction

A VPython tutorial

Pictures of 3D objects

Choose an object:

Work with objects:

Windows & Events:

What's new in Visual 5

VPython web site
Visual license
Python web site
Math module (sqrt etc.)
Numpy module (arrays)

The Visual Module of VPython

Version 5.74


VPython is the Python programming language plus a 3D graphics module called "Visual" originated by David Scherer in 2000. This documentation describes all of the Visual capabilities.

VPython documentation is included with the VPython installer and is accessible from the Help menu in the VIDLE program editor. Documentation for the new VPython 6 is included with VPython 6 installers.

For a quick introduction, see youtube.com/vpythonvideos

Descriptions of the options available in the left margin:

Introduction: The basics of Python and VPython.

Tutorial: More on VPython, including making an animation

Pictures of 3D objects: What the objects look like

Choose a 3D object (use pull-down menu on left): Details of cylinder, box, etc. Start with cylinder for an overview.

Work with 3D objects (use pull-down menu on left): Issues that apply to all 3D objects: color, material, etc.

Windows, Events, & Files (use pull-down menu on left): Creating/modifying windows; handling mouse/ keyboard events; reading/writing files

Vector operations: Magnitude, dot and cross product, rotation, etc.

Graphs: Making graphs of data.

factorial/combin: Special functions used in probability calculations.

What's new: Features new in Visual 5.

Be sure to explore the many example programs that are installed with Visual.


To invoke the Visual module, place the following statement at the start of the file:

from visual import *

If you are using Python 2.7 or earlier, to make sure that 3/4 is treated as 0.75 rather than zero, start your program with the following statements (there are two underlines before future and two underlines after future):

from __future__ import division
from visual import *

This is not necessary with Python 3.0 or later, but it doesn't hurt, and including the division statement ensures that your program will handle division the same way on all versions of Python.

For experienced programmers

As a convenience to novice programmers to provide everything that is needed to get started, the statement "from visual import *" imports all of the Visual features and executes "from math import *" and "from numpy import *". It also arranges that for routines common to both math and numpy such as sqrt, the much faster math routine is used when possible (when the argument is a scalar rather than an array).

If you want to import the visual objects selectively, import them from the vis module. Two simple examples:

import vis


from vis import (box, color, materials)
box(color=color.orange, material=materials.wood)

There are clean modules vis.controls, vis.filedialog, and vis.graph equivalent to the modules visual.controls, visual.filedialog, and visual.graph. The latter versions execute "from visual import *" and are retained because some programs expect that behavior when importing one of these modules.

The documentation is written assuming that "from visual import *" is used.

VPython documentation was produced by Ruth Chabay, David Scherer, and Bruce Sherwood.