bokeh / jupyter_bokeh

An extension for rendering Bokeh content in JupyterLab notebooks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'Document' object has no attribute 'apply_json_event' (jupyter_bokeh/widgets.py:135)

xareelee opened this issue · comments

Env

macOS == 13.3.1
VSCode == 1.77.3 (my IDE)
poetry == 1.4.2 (Python package manager)

In poetry venv:

python == 3.11.3
jupyter == 1.0.0
ipykernel == 6.22.0
ipywidgets == 8.0.6

pandas == 2.0.0
bokeh == 2.4.3
panel == 0.14.4 (depending on bokeh >=2.4.0 && < 2.5.0)
jupyter_bokeh == 3.0.2 (not 3.0.7, because of panel dependency)

Issue

I'm following the tutorial of Panel, run the following code in Jupyter Notebook in VScode, and encounter this error when trying to show a holoview:

# Jupyter Notebook cell in VScode
first_app = pn.Column(window, sigma, interactive)

first_app
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
File {path_to_project}/.venv/lib/python3.11/site-packages/jupyter_bokeh/widgets.py:135, in BokehModel._sync_model(self, _, content, _buffers)
    133         cb(attr, old, new)
    134 elif kind == 'MessageSent':
--> 135     self._document.apply_json_event(content["msg_data"])

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

Do I miss something?

Your versions are incompatible. I expect you will need an older version of jupyter_bokeh or a newer version of Bokeh

cc @mattpap @philippjfr

Edit: also since this concerns a panel tutorial, the issue really belongs on their tracker (it is up to them to provide reliable setup instructions/configurations for their tutorials)

bokeh 3.x implies jupyter_bokeh 3.0.7 and panel 1.x. @xareelee you can try using beta version of panel from pyviz channel. The latest is panel 1.0.0b16.

@mattpap @bryevdv
I've done all suggestions, but I can't make my code to render with Jupyter Notebook in VSCode .

panel #1.0.0b16
bokeh #3.1.0
jupyter_bokeh #3.0.7
jupyterlab #3.6.3

Screenshot 2023-04-22 at 18 27 51

@xareelee I don't use jupyter much and I don't use jupyter in vscode at all. I can't really offer any other advice. Normally I would advise anyone to look at a browser's JavaScipt console for any relevant errors, messages etc. If there is some way to do similar for vscode (I don't know) I'd advise reporting on that.