vpython / vpython-jupyter

3D visualization made easy
MIT License
138 stars 64 forks source link

Jupyter in VS Code - Wait for websocket to connect #172

Open smrfeld opened 3 years ago

smrfeld commented 3 years ago

Hi, I am running a notebook in VS code with the tutorial commands:

from vpython import *
sphere()

The first command finishes but the second hangs on this line from the stack trace:

KeyboardInterrupt
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-2-b919c6b7ad5b> in <module>
----> 1 sphere()

~/opt/anaconda3/lib/python3.7/site-packages/vpython/vpython.py in __init__(self, **args)
   1148         args['_default_size'] = vector(2,2,2)
   1149         args['_objName'] = "sphere"
-> 1150         super(sphere, self).setup(args)
   1151         self._sizing = False # no axis/size connection
   1152 

~/opt/anaconda3/lib/python3.7/site-packages/vpython/vpython.py in setup(self, args)
    582 
    583     def setup(self, args):
--> 584         super(standardAttributes, self).__init__()
    585         self._constructing = True  ## calls to setters are from constructor
    586 

~/opt/anaconda3/lib/python3.7/site-packages/vpython/vpython.py in __init__(self, **kwargs)
    236                 baseObj._canvas_constructing):
    237             if _isnotebook:
--> 238                 from .with_notebook import _
    239             else:
    240                 from .no_notebook import _

~/opt/anaconda3/lib/python3.7/site-packages/vpython/with_notebook.py in <module>
    151 baseObj.glow = GlowWidget(wsport=__SOCKET_PORT, wsuri='/ws')
    152 while (not wsConnected):
--> 153     time.sleep(0.1)          # wait for websocket to connect
    154 
    155 baseObj.trigger()  # start the trigger ping-pong process

KeyboardInterrupt: 
BruceSherwood commented 3 years ago

What do you see if you simply execute print(version)? Can you run a simple Jupyter notebook program from a different launcher, outside of VSC?

smrfeld commented 3 years ago

The version output is:

['7.6.2', 'jupyter']

I also tried from jupyter-lab now with the same result

BruceSherwood commented 3 years ago

How about jupyter notebook?

jeb12301 commented 2 years ago

Hi, I am getting the exact same error running vpython in jupyterlab

Python 3.8.12 Jupyterlab 3.2.1-1