using vpython in thonny

74 views
Skip to first unread message

Chuck O

unread,
Dec 6, 2024, 1:09:47 AM12/6/24
to thonny
Hi All,

I'm just getting started in Python using Veit Steinkamp's new book "Python for Engineering and Scientific Computing".  He recommends thonny and claims that all examples in the book can be run in it.

I downloaded thonny, and then used the Package Manager to download numpy, matplotlib, sympy, scipy, and vpython.  Everything works fine except for the example program using vpython (attached).  When I run it from thonny, I get a tab opening up in my browser (Chrome), but nothing happens in the tab.  I'm still using Windows 10 if that matters.

Any suggestions? A later chapter says that vpython runs within the WebGL interface.  Do I need to set something in Chrome?

Thanks! 
01.05_vpython_program.py

Paul Naish

unread,
Dec 6, 2024, 8:54:39 AM12/6/24
to thonny
I don't have the book, nor any experience with vpython, but I'd suggest looking in the book for potential contacts you can ask. Go back to the source.

Chuck O

unread,
Dec 6, 2024, 9:31:45 AM12/6/24
to thonny
Hi Paul.  I thought of that and looked in the book for a way to contact the author, but no luck.  It's a very new book so there's not much internet buzz on it yet either.  Looking thru some other chat rooms I came across a gentleman who could get vpython to work in IDLE but not THONNY.  There doesn't seem to be much on vpython in this thonny group conversation, just a reference from 5 years ago suggesting that it was a temporary issue to do with  version compatibility.  I'm hoping there's an answer, since I do like thonny so far.

Thanks,
Chuck

Paul Naish

unread,
Dec 6, 2024, 9:34:07 AM12/6/24
to thonny
My curiosity got the better of me.

I used PIP to load vpython (what a monster of a module!)

I'm using Thonny 4.1.4 on Windows with Python 3.12.3

Windows asked for permission to access the local directory where vpython was saved. I gave it permission but still no joy.

I modified the code to check what was happening and had the ball dropping through the surface. 

As I said, I don't know vpython but one thought is there is no pause that would allow the ball to be viewed. In other words, it's running but you only see the initial position because the program is running too fast. The introduction of the print statements introduces a brief pause. Still there seems to be a logic problem if the ball is suppose to bounce.

01.05_vpython_program_debug.py

Paul Naish

unread,
Dec 6, 2024, 9:35:53 AM12/6/24
to thonny
"...  I came across a gentleman who could get vpython to work in IDLE but not THONNY". Try just running it from a terminal window. No need to run it in a IDE.

Chuck O

unread,
Dec 6, 2024, 3:35:14 PM12/6/24
to thonny
Right then.  At this point I've figured out the problem has nothing to do with thonny.

In the  vpython group forum , I found someone who had a similar problem under "no visual output".  The first responder suggested:

     1) The first thing to check is weather or not your browser supports webgl.
          https://get.webgl.org

     2) If it does then you should be able to run the example web vpython programs here.

The first check worked fine for me, but the second check would keep giving me "Error: Can't create canvas: WebGL not supported" for any of the example programs.

So I tried running the vpython examples from the above link on my wife's newer computer and it worked just fine. (Microsoft keeps telling me I need a new computer...)

Thanks for all the suggestions.  
Chuck 

Chuck O

unread,
Dec 14, 2024, 9:40:44 AM12/14/24
to thonny
One last update.  I was finally able to get Vpython to work in Chrome on an old PC by turning off the graphics accelerator in Chrome.  To do this:
  1. Go to Chrome Settings
  2. Go to System
  3. Turn off " Use graphics acceleration when available" option, then hit the "Relaunch" button beside it.
Vpython graphics won't be necessarily be fast, but they'll work. 

Reply all
Reply to author
Forward
0 new messages