jupyter_bokeh icon indicating copy to clipboard operation
jupyter_bokeh copied to clipboard

Error while running notebooks in VS Code

Open alexgleith opened this issue 1 year ago • 3 comments

If I run a simple example like the below in VS Code:

import numpy as np
import holoviews as hv

def sine_curve(phase, freq):
    xvals = [0.1* i for i in range(100)]
    return hv.Curve((xvals, [np.sin(phase+freq*x) for x in xvals]))

# When run live, this cell's output should match the behavior of the GIF below
dmap = hv.DynamicMap(sine_curve, kdims=['phase', 'frequency'])
dmap.redim.range(phase=(0.5,1), frequency=(0.5,1.25))

I get the error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
File [/opt/homebrew/lib/python3.11/site-packages/jupyter_bokeh/widgets.py:133](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/lib/python3.11/site-packages/jupyter_bokeh/widgets.py:133), in BokehModel._sync_model(self, _, content, _buffers)
    131         cb(attr, old, new)
    132 elif kind == 'MessageSent':
--> 133     self._document.apply_json_event(content["msg_data"])

AttributeError: 'Document' object has no attribute 'apply_json_event'

Libraries I have installed include:

  • bokeh==2.4.3
  • jupyter-bokeh==2.0.4
  • notebook==6.5.4
  • holoviews==1.16.0
  • hvplot==0.8.3

VS Code is: 1.78.2 running on a M1 mac.

Also note that if I run the same example in Jupyter Lab on the same machine it renders fine, but seems to not have interactivity.

image

alexgleith avatar May 17 '23 22:05 alexgleith

bokeh==2.4.3 jupyter-bokeh==2.0.4

It looks like jupyter-bokeh compatible with bokeh 2.4 was never published. The last working version is probably bokeh 2.3. Note that holoviz stack based on bokeh 3 was published yesterday, so if you don't mind updating your dependencies, then this may be a non-issue for you. We probably will want to make a retroactive 2.0.5 release anyway.

mattpap avatar May 18 '23 09:05 mattpap

I have a working local environment now. It was pretty hard to work out what needed to change, but this combination is ok:

bokeh==2.4.3
jupyter-bokeh==3.0.5

Can render in VS Code now, although I can't work out if I need to execute this or not: hv.extension('bokeh')

alexgleith avatar May 18 '23 22:05 alexgleith

although I can't work out if I need to execute this or not: hv.extension('bokeh')

Holoviews is a separate project, that's really a question for them: https://discourse.holoviz.org but there may also be useful information here: https://github.com/bokeh/bokeh/issues/10765

TLDR; Microsoft does not use standard websockets and that's an issue

bryevdv avatar May 18 '23 22:05 bryevdv