Error in atexit._run_exitfuncs:

1,226 views
Skip to first unread message

Raspberry Pieman

unread,
Aug 16, 2022, 5:25:11 AM8/16/22
to VPython-users
Hi,
  I have recently installed vpython, using pip install vpython for my Python 3.9 on Windows/10 Home.

I tried to run this simple 2 line program:

import vpython
print('done')

When run under Python 3.9 IDLE - it runs as expected.

However, if I try to run it on a CMD prompt window, I get the following error:

C:\Users\Raspberry\AppData\Local\Programs\Python\Python39>python Y:\Source\Python\_Python3\vPython\vPythonintro.py
done
exit
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "C:\Users\Raspberry\AppData\Local\Programs\Python\Python39\lib\site-packages\vpython\vpython.py", line 22, in Exit
    a = 1.0/zero
ZeroDivisionError: float division by zero

It seems to run OK, but falls over on the exit process.
If I comment-out the import vpython line - it runs with no error, so I know its related to vpython.

I have thousands of working Python programs and this is the first time I have been stumped for an answer.

Any ideas?
I eventually need to run it from VScode, but I need to resolve this first.





Stephen Spicklemire

unread,
Aug 16, 2022, 7:37:34 AM8/16/22
to 'Ian Beatty' via VPython-users, Steve Spicklemire
I’m not positive, but I think this may have been deliberately added at some point when some users were having trouble with windows cmd line programs hanging and not even allowing ctrl-c to interrupt them. I can try to go through the commits to see if there’s an explanation, but I guess the point is that this appears to be the intended behavior.

-steve
> --
> You received this message because you are subscribed to the Google Groups "VPython-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vpython-user...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/vpython-users/b8cbedf1-40b7-437c-8d67-d4005dc3da18n%40googlegroups.com.

Raspberry Pieman

unread,
Aug 16, 2022, 11:07:44 AM8/16/22
to vpytho...@googlegroups.com
Steve,
     Thanks for looking into this.
I look forward to your findings.
If it is intended, then perhaps there should be some explanation in the documentation?
Martyn

Bruce Sherwood

unread,
Aug 16, 2022, 11:19:01 AM8/16/22
to VPython-users
There is indeed a problem with running a VPython program from a terminal. This modality works somewhat better if you add the following to the end of your program: "while True: rate(30)", though you may still have difficulty exiting.

Bruce

Bruce Sherwood

unread,
Aug 16, 2022, 11:39:27 AM8/16/22
to VPython-users
Correction: Instead of calling rate(), import time and add this to the end of your program:

while True: time.sleep(0.03)

I find on Windows that executing ctrl-c twice gets me out of the program. In any case, we're not doing a good job of running VPython from a terminal.

Bruce

Bruce Sherwood

unread,
Aug 16, 2022, 12:35:30 PM8/16/22
to VPython-users
I forgot something. I think I'm using a corrected version of 7.6.4, in which at the end of the file ..Lib/site-packages/vpython/no_notebook.py Steve changed the while loop to this:

while not (httpserving and websocketserving): # try to make sure setup is complete
    time.sleep(0.1)

This doesn't fix all the problems with running from a terminal but it does help.

Bruce

Aaron Titus

unread,
Aug 28, 2022, 8:25:52 PM8/28/22
to vpytho...@googlegroups.com
FYI I get the same error message.

I created an condo environment and installed vpython using:

conda install -c vpython vpython


I ran ipython and typed:

import vpython as vp
vp.sphere()


When I exit the browser tab with the vpython scene, I get the following error:

Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/Users/atitus/opt/anaconda3/envs/ncsu/lib/python3.8/site-packages/vpython/vpython.py", line 22, in Exit

    a = 1.0/zero
ZeroDivisionError: float division by zero


And ipython exits after the error.

I’ll try installing a previous version of vpython to see if I can get around it.

Aaron

Reply all
Reply to author
Forward
0 new messages