'VPython acts weird when used with python installation and won't shut down nicely

I want to build physics simulations using VPython. Although, VPython works great on websites like trinket.io, I'd like to use a nicer IDE than the web one, and I'd like to use real python modules as well as external libraries like numpy.

I followed the instructions at https://vpython.org/presentation2018/install.html to install VPython locally. I used the command pip install vpython (not really a fan of conda) and wrote this simple demo program:

from vpython import sphere

sphere()

When I ran this from the command line, the program indeed worked: a browser window opened displaying the sphere. However, there are several issues with this setup:

  • When looking at the console, it keeps throwing a weird error RuntimeError: can't register atexit after shutdown. However, it still seems to run fine.
  • I couldn't find a way to nicely stop the simulation. Closing the browser tab doesn't exit the program. Pressing Ctrl+C also doesn't do anything useful. The only way to stop it is to use Ctrl+Break, which is a really dirty way, in my opinion. I tried to use stop_server as documented in that link, but no result.

Is there a way to fix these issues or maybe a different environment that will answer my needs? I really want to be able to use built-in python modules and external libraries like numpy but it seems impossible at the moment.



Solution 1:[1]

It's a matter of Python versions as per this discussion.

There was a discussion on a mismatch between the vpython release and the used python interpretter:

We are behind. The builds for 7.6.1 were done for Python 3.6, 3.7, and 3.8, not 3.9. So it might be that it would work if you downgraded Python. Bruce

You're correct, thanks! I downgraded to 3.8.6 and it worked.

Solution 2:[2]

To exit the program, you need to stop the terminal by entering the exit command.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Abdullahmc