Jupyter VPython

211 views
Skip to first unread message

Bruce Sherwood

unread,
Apr 8, 2016, 6:41:03 PM4/8/16
to Teaching with Jupyter Notebooks
"pip install vpython" installs an unusual module that makes it quite easy instead of extremely difficult to write Python programs that display real-time navigable 3D animations in a Jupyter notebook. Details are provided on the first page of vpython.org. VPython is used extensively in physics education, where its simplicity makes it possible for students with no previous programming experience to write Python programs to model dynamical physical systems in 3D, with the 3D graphics produced essentially as a side effect of physics calculations. See matterandinteractions.org.

Consider for example the following remarkably short program which displays a 3D cube, positions the camera so that the scene fills the canvas, sets up appropriate lighting, and activates mouse or touch controls to rotate and zoom the camera:

from vpython import *
box()

Most 3D libraries require a great deal of code to accomplish this.

You can run vpython demo programs at Binder, even on mobile devices:


Classic VPython was created in 2000 by David Scherer, a student at Carnegie Mellon University. Its core is written in C++. In 2014 John Coady created a pure Python implementation of the Classic VPython API which sends data to a Jupyter notebook that invokes the GlowScript 3D libraries, which are based on WebGL. Ruth Chabay and I have been working with Coady to implement the GlowScript VPython API, which is somewhat different from the classic API but better adapted to the browser/GPU world. Because the API is the same, identical code can run in a Jupyter notebook or in the pure browser GlowScript environment (glowscript.org), where the RapydScript Python-to-JavaScript transpiler runs in the browser. (Currently widget invocation is different in the two versions; it is planned to provide wrappers around the Jupyter and jquery widgets so that widget code will also be transportable between the two environments.)

The GlowScript environment is particularly appropriate for novice programmers, whereas Jupyter VPython is better suited for professionals, because it provides access to all standard Python modules, which is not possible in the JavaScript-based GlowScript environment.

Although Jupyter VPython is already quite fast, as can be seen in some of the demo programs, John, Ruth, and I intend to use Cython to make it significantly faster.

Bruce Sherwood

Bruce Sherwood

unread,
Apr 9, 2016, 12:25:08 AM4/9/16
to Teaching with Jupyter Notebooks
Sometimes one can get the message "I couldn't find a kernel matching VPython. Please select a kernel." You are then offered a list of notebooks that includes VPython, which one needs to choose. I don't get these messages when running the programs on my own computer.

Is this a bug in Binder, or is the notebook type not part of the notebook?

Bruce Sherwood

unread,
Apr 9, 2016, 11:35:33 PM4/9/16
to Teaching with Jupyter Notebooks
0.3.6: Fixes some bugs; RotatingBoxes runs MUCH faster, Stonehenge fly-through now works better.

Jess Hamrick

unread,
Apr 10, 2016, 1:19:43 PM4/10/16
to Bruce Sherwood, Teaching with Jupyter Notebooks
This is very cool! Thanks for sharing!

Re: the error message "I couldn't find a kernel matching VPython. Please select a kernel.”, I’m not sure where that is coming from, but it sounds like a bug in the kernel or in the notebook to me, because the VPython kernel is clearly installed and you can choose it from the list. I would try reporting it as an issue on the jupyter/notebook repo.

Cheers,
Jess


On Apr 9, 2016, at 8:35 PM, Bruce Sherwood <bruce.s...@gmail.com> wrote:

0.3.6: Fixes some bugs; RotatingBoxes runs MUCH faster, Stonehenge fly-through now works better.

--
You received this message because you are subscribed to the Google Groups "Teaching with Jupyter Notebooks" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter-educat...@googlegroups.com.
To post to this group, send email to jupyter-...@googlegroups.com.
Visit this group at https://groups.google.com/group/jupyter-education.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter-education/c7a7fc2b-a1f1-4ea6-ba86-c7c4375ec3c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bruce Sherwood

unread,
Apr 11, 2016, 12:38:43 AM4/11/16
to Jess Hamrick, Teaching with Jupyter Notebooks
Good point. I decided to report the bug (if that is what it is) to binder-project/binder, as it seems more likely to be a binder bug than a jupyter bug.

Bruce

Bruce Sherwood

unread,
Apr 15, 2016, 11:30:19 PM4/15/16
to Teaching with Jupyter Notebooks
This problem turned out to be a mistake on my part. Some of the notebooks contained the wrong kernel reference. This has been fixed.

idbe...@uncg.edu

unread,
Jan 7, 2019, 2:32:46 PM1/7/19
to Teaching with Jupyter Notebooks
Hi, Bruce.

When I try to run, via Binder, any of the notebooks in Demos (well, I tried three different ones), I'm getting an error message instead of a simulation: "Must have at least version 0.35 of JupyterLab". This happens even when I switch into "Trusted" mode.

I'm using Firefox 64.0 (latest) on Mac OS X 10.14.2 (latest).

Thoughts?

// Ian

mattw...@gmail.com

unread,
Jan 7, 2019, 5:09:29 PM1/7/19
to Teaching with Jupyter Notebooks
Hi,

That is happening because of a change I made -- the message printed to the screen I can drop easy enough (and it is unrelated to the issue with vpython not running).

The underlying error is that we changed some of the plumbing with how the notebook case works, and it worked on my machine but seems to be failing with Binder.

Do you need binder working right away? If so I can give you a link to a binder with the last released version of vpython (which should work immediately).

I'm not entirely sure how long it will take to sort this out...


Matt Craig

Bruce Sherwood

unread,
Jan 7, 2019, 6:15:47 PM1/7/19
to mattw...@gmail.com, Teaching with Jupyter Notebooks
I don't consider the binder venue particularly important; it just seemed a somewhat useful way for people to get a look at vpython before deciding to install it. So I don't feel that there's any real priority getting it to run again.

Bruce

Ian Beatty

unread,
Jan 7, 2019, 6:27:34 PM1/7/19
to Teaching with Jupyter Notebooks
Hi, Matt.

No, there is no urgency to this. I was back-reading through old list posts, came across Bruce’s link to the demo programs, and thought I’d see how it looked. And then I figured y’all ought to know about the scary error…

At present, I’m doing technology research before delving into the design of an ENTIRELY REDESIGNED computational physics curriculum, as I dump Mathematica in favor of python + jupyter and simultaneously move our program from a pairof one-credit computational physics “labs” to a pair of three-credit computational physics courses plus computational assignments integrated into all our other courses… :) :) :)

Thanks // Ian

Dr. Ian Beatty
Associate Professor & Director of Undergraduate Studies
Dept. of Physics & Astronomy, UNC Greensboro
321 Petty Bldg, Greensboro NC 27402-6170 USA
idbe...@uncg.edu, 336.645.5002, twitter: @idbeatty, http://ianbeatty.com

On Jan 7, 2019, 6:15 PM -0500, Bruce Sherwood <bruce.s...@gmail.com>, wrote:
I don't consider the binder venue particularly important; it just seemed a somewhat useful way for people to get a look at vpython before deciding to install it. So I don't feel that there's any real priority getting it to run again.

Bruce

--
You received this message because you are subscribed to a topic in the Google Groups "Teaching with Jupyter Notebooks" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jupyter-education/Osa1Avf2C-Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jupyter-educat...@googlegroups.com.

To post to this group, send email to jupyter-...@googlegroups.com.
Visit this group at https://groups.google.com/group/jupyter-education.

kirby urner

unread,
Jan 7, 2019, 6:33:07 PM1/7/19
to Teaching with Jupyter Notebooks

Yeah I went there immediately as showcasing w/ mybinder.org is a topic of interest, and I've always been a fan of VPython since the beginning.  I'll monitor this listserv for news on that front, in case you fix it.

Kirby Urner

mattw...@gmail.com

unread,
Jan 7, 2019, 6:36:40 PM1/7/19
to Teaching with Jupyter Notebooks
Hi,


Looks like there is a little more setup we need to do to make sure vpython will work in hosted environments like binder...

It would be nice to get this working, it is a really easy way to show off vpython.


Matt
Reply all
Reply to author
Forward
0 new messages