Home

Documentation

Download:
   Windows
   Macintosh
   Linux

New in VPython 6

Change log

VPython wiki

User forum

Contributed programs

For developers

Python web site

 

VPython
3D Programming for Ordinary Mortals

stonehenge

VPython makes it easy to create navigable 3D displays and animations, even for those with limited programming experience. Because it is based on Python, it also has much to offer for experienced programmers and researchers.

For a quick introduction, see these YouTube videos:

3D Objects

Variable Assignment

Beginning Loops

Loops and Animation

Scale Factors

Debugging Syntax Errors

Lists, Part 1

Lists, Part 2

How to get started using VPython

New to Python and/or VPython?  GlowScript VPython is a good place to start:

·         Go to glowscript.org and create an account.   

o   You should see the sentence “You are signed in as <yourusername> and your programs are here." Click on "here”.

o   Click on “Create New Program”.  Name it “box”.  Below the line
Glowscript 2.0 VPython
type this:
box()

·         Then click on “Run this program”.  You will see a white box on a black background.

o   Use the right button (or CTRL-drag left button) of the mouse to rotate the camera to view the scene from different angles.

o   To zoom in and out use two buttons, or ALT/OPTION-drag, or the mouse scrollwheel. Touch screen:  swipe or two-finger rotate; pinch/extend to zoom.

o   Click on VPython Help to see what graphical objects are available.

Experienced Python / VPython user?  Jupyter VPython uses the popular IPython/Jupyter professional programming environment:

·         Install the Continuum Anaconda (or Enthought Canopy) Python distribution.  We recommend choosing Anaconda with Python 3.x, especially if you already have “Classic” VPython / Python 2.7 installed on your machine (Canopy uses Python 2.7).  If you are an expert Python user, you can install the IPython and Jupyter modules in your current Python installation; see jupyter.org.

·         In a Power Shell or Command Prompt (Windows) or Terminal (Mac / Linux) run this command:
pip install vpython
There will be frequent updates to this module. You can get the latest version this way:
pip install vpython --upgrade

 

·         Create a Jupyter notebook (see below) and start your program with
from vpython import *


or other vpython import statement.  If you choose a “VPython” type of notebook, it will automatically execute these necessary statements before importing vpython:
from __future__ import division, print_function
from math import *

There are two ways to start a Jupyter notebook. In a terminal, execute "jupyter notebook". Or (depending on what operating system you're using), doubleclick the icon "Jupyter Notebook" that is shown as one of the Anaconda-related tools. At the right there is a pulldown menu to create a New notebook, and if you choose "VPython" you will get the imports described above. You can at any time change the kind of notebook through the menu Kernel > Change kernel.

Click in the first cell (containing the import vpython statement), then click the run icon, the one that is a rightward-facing triangle touching a vertical line. Currently, to re-run a VPython program you need to click the circular arrow icon to "restart the kernel" and then click the red-highlighted button, then click in the first cell, then click the run icon. It is intended to make this much simpler in the future by customizing the Jupyter notebook.

 

·         Rotating and zooming the camera is the same as for GlowScript VPython; see above.

·         See the GlowScript VPython Help for documentation. The only GlowScript object not yet implemented is the extrusion object. Mouse interactions are now fully enabled, including scene.mouse.pick. Keyboard interactions are not yet enabled pending an understanding of the relationship to keyboard inputs being processed by the Jupyter notebook.

·         Here is a zip file with a set of demo programs.

·         There is a Binder package of the demo programs, which lets you run the Jupyter VPython programs even on computers or mobile devices that do not have Python installed. Here is an explanation of the Binder mechanism. Because the Binder servers are shared among a large number of people, performance can vary a great deal from day to day and from hour to hour.

·         Matt Craig provides an alternative way to install on Anaconda. For users who DO NOT have the Classic VPython Anaconda package installed: "conda install -c vpython vpython". Those who DO have Classic VPython installed and want to keep it should instead create a new environment in which to try the new VPython: "conda create -c vpython -n vpython_jup_env vpython python". After creating the new environment you will need to activate it to try out the new VPython. To upgrade to a more recent version, execute "conda update -c vpython vpython".

How GlowScript VPython and Jupyter VPython differ from Classic VPython

·         Vectors must be represented as vector(x,y,z) or vec(x,y,z), not as (x,y,z).

·         The name display has been changed to canvas (for technical reasons).

·         The name gdisplay has been changed to graph.

·         curve objects and points objects have a new set of methods.

In the VPython Help at glowscript.org is a conversion program to convert from Classic to GlowScript syntax; It does an imperfect but useful job of dealing with the main differences.

To Download Classic VPython:

·         Click the appropriate Download option on this page, and follow the instructions.  Rotating and zooming the camera is the same as for GlowScript VPython except that neither touch nor the mouse scrollwheel are supported.

·         Classic VPython will remain available, but will not henceforth be updated.

More information about VPython and future developments

·         Here is a description of the plan for future development of VPython.

 

 

Descriptions of the Classic VPython options available at the top of the left margin:

Documentation: Overview, tutorials, and detailed documentation

Download: Free downloads for Windows, Macintosh, and Linux

What's new in VPython 6: New mouse/keyboard handling; native buttons, sliders, etc.

Change log: History of changes

User forum. (Until Feb. 2013, there was a mailing list whose archives may be found at https://sourceforge.net/mailarchive/forum.php?forum_name=visualpython-users. Please do not write to that list; instead post on the User forum.)

Contributed programs: Interesting and useful programs contributed by users

For developers: For those interested in contributing to further development of Python

Python web site: The Python programming language, on which VPython is based

Other:

Jay Wang has posted a gallery of photos and movies of a variety of interesting VPython programs.

A podcast interview with Ruth Chabay and Bruce Sherwood about the history of VPython.

A poster on the relationship between GlowScript VPython and Jupyter VPython

VIDLE: alternative to IDLE which fixes some significant problems

Matter & Interactions: Introductory physics using VPython

Some advanced-level textbooks in which VPython is used:

Computational Physics:Problem Solving with Python, Rubin H. Landau, Manuel J. Páez, Cristian Bordeianu (2015)

Computational Physics with Python Mark Newman (2012)

An Introduction to Statistical Mechanics and Thermodynamics Robert H. Swendsen (2012)

Equilibrium Statistical Physics With Computer Simulations in Python Leonard M. Sander (2013)

Soil Physics with Python: Transport in the Soil-Plant-Atmosphere System
Marco Bittelli, Gaylon S. Campbell, and Fausto Tomei (2015)

Computational Modeling and Visualization of Physical Systems with Python Jay Wang (2016)

Write to if you don't find what you need, or to tell us how you are using VPython.

Hindi translation of this page provided by MHA Degree.

Malayalam translation of this page provided by How to Become a Technician Team

Greek translation of this page provided by Nikolaos Zinas.

Romanian translation of this page provided by PCWDLD.com

Development of VPython was supported in part by the National Science Foundation