VPython

raw JSON →
7.6.5 verified Sat May 09 auth: no python

VPython is a 3D programming environment for Python, enabling easy creation of navigable 3D animations and simulations. This version (7.6.5) is designed for Jupyter Notebook and requires Python >= 3.7. It uses WebGL for rendering in the browser. Release cadence is irregular, with updates focused on bug fixes and Jupyter compatibility.

pip install vpython
error ModuleNotFoundError: No module named 'visual'
cause VPython 7 replaced the classic 'visual' module with 'vpython'.
fix
Replace 'from visual import *' with 'import vpython as vp' and use vp.canvas(), vp.sphere(), etc.
error NameError: name 'sphere' is not defined
cause When using wildcard import 'from vpython import *', the 'sphere' function exists but may conflict with other names. More commonly, the namespace was omitted.
fix
Use explicit import: 'import vpython as vp' then 'vp.sphere(...)'.
error TypeError: unsupported operand type(s) for +: 'NoneType' and 'NoneType'
cause Attempting to use VPython code outside Jupyter returns None for all objects; arithmetic on None produces this error.
fix
Ensure code runs in a Jupyter notebook cell.
breaking VPython 7 is a complete rewrite from VPython 6; the API and rendering engine are entirely different. Code written for VPython 6 (classic) will not work.
fix Migrate to VPython 7 syntax: use 'vpython' module, 'canvas()', 'vector()', and avoid 'visual' module.
breaking VPython 7 only runs in Jupyter Notebook or JupyterLab (classic). It does not work in other Python IDEs or command-line scripts.
fix Install Jupyter and run code in a notebook cell. Use 'pip install jupyter' then 'jupyter notebook'.
gotcha Running VPython code outside Jupyter (e.g., in a plain Python script) produces no output or error; it silently does nothing.
fix Always run VPython 7 code inside a Jupyter notebook cell.

Creates a 3D scene with a red sphere. Must be run in a Jupyter Notebook; VPython renders inline.

import vpython as vp

scene = vp.canvas()
sphere = vp.sphere(pos=vp.vector(0,0,0), radius=1, color=vp.color.red)
# To view, run in a Jupyter Notebook cell