Search code examples
pythonpython-3.xvpython

VPython 7 - No module visual is found


I'm working through some Python examples in a book. Many of the codes listed calls for a module visual. I believe visual was installed in older versions of Vpython. I am running Python 3.6 with Vpython 7 installed. I use a Mac computer. Many of the sample codes start with lines such as the following:

 from visual import *                  
 from visual.graph import *
 from visual.graph import gdisplay, gcurve
 from visual.controls import slider, controls, toggle

I learned from an internet search to replace the first line with:

from vpython import *

This doesn't work for other visual calls. My programs keep crashing because no module visual is found. Is there a way to get these calls to work?


Solution

  • There exists a conversion program to convert from Classic VPython to the new VPython 7. See details here.

    http://www.glowscript.org/docs/VPythonDocs/index.html

    where is says ...

    "Many programs written in Classic VPython 6 will run in GlowScript VPython or VPython 7 without change after being run through a conversion program written in Python. This program converts (x,y,z) => vector(x,y,z) and obj.x => obj.pos.x. These changes are necessary because GlowScript does not recognize (x,y,z) as a vector nor obj.x as a shorthand for obj.pos.x. The program also converts display => canvas and gdisplay => graph. The program also converts scene.mouse.getclick() => scene.waitfor('click'), which works in both environments."

    the python conversion program is.

    http://www.glowscript.org/docs/GlowScriptDocs/VPtoGS.py