Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempting to display anything with Panel in a Jupyter Notebook in VS Code errors #6333

Closed
1 task
droumis opened this issue Feb 10, 2024 · 2 comments
Closed
1 task
Labels
TRIAGE Default label for untriaged issues

Comments

@droumis
Copy link
Member

droumis commented Feb 10, 2024

ALL software version info

VSCODE: Version: 1.86.0

Python : 3.10.13 | packaged by conda-forge | (main, Dec 23 2023, 15:35:25) [Clang 16.0.6 ]
Operating system : macOS-13.5.2-arm64-arm-64bit
Panel comms : vscode
holoviews : 1.18.2
bokeh : 3.3.4
IPython : 8.21.0
jupyter_bokeh : 2.0.4
jupyterlab : 4.1.0
notebook : 7.0.7
panel : 1.3.8
param : 2.0.2
pyviz_comms : 3.0.0

Description of expected behavior and the observed behavior

Trying to displaying anything with Panel in a Jupyter Notebook in VS Code sometimes errors. The same cell executed in JupyterLab works fine.

I haven't been able to figure out under what conditions this occurs. As far as I've been able to tell, it will happen sometimes without changing anything in my env and then at some point start working again.

Complete, minimal, self-contained example code that reproduces the issue

import panel as pn; pn.extension()
pn.pane.Markdown('## Hello, World!')

Stack traceback and/or browser JavaScript console output

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
File ~/opt/miniconda3/envs/demo-cv2/lib/python3.10/site-packages/IPython/core/formatters.py:974, in MimeBundleFormatter.__call__(self, obj, include, exclude)
    971     method = get_real_method(obj, self.print_method)
    973     if method is not None:
--> 974         return method(include=include, exclude=exclude)
    975     return None
    976 else:

File ~/opt/miniconda3/envs/demo-cv2/lib/python3.10/site-packages/panel/viewable.py:782, in Viewable._repr_mimebundle_(self, include, exclude)
    779     loaded = hv.extension._loaded
    781 if config.comms in ('vscode', 'ipywidgets'):
--> 782     widget = ipywidget(self)
    783     if hasattr(widget, '_repr_mimebundle_'):
    784         return widget._repr_mimebundle_(include=include, exclude=exclude), {}

File ~/opt/miniconda3/envs/demo-cv2/lib/python3.10/site-packages/panel/io/notebook.py:555, in ipywidget(obj, doc, **kwargs)
    553 doc = doc if doc else Document()
    554 model = panel(obj, **kwargs).get_root(doc=doc)
--> 555 widget = BokehModel(model, combine_events=True)
    556 if hasattr(widget, '_view_count'):
    557     widget._view_count = 0

File ~/opt/miniconda3/envs/demo-cv2/lib/python3.10/site-packages/jupyter_bokeh/widgets.py:68, in BokehModel.__init__(self, model, **kwargs)
     66 def __init__(self, model, **kwargs):
     67     assert isinstance(model, LayoutDOM)
---> 68     self.update_from_model(model)
     69     super(BokehModel, self).__init__(**kwargs)
     70     self.on_msg(self._sync_model)

File ~/opt/miniconda3/envs/demo-cv2/lib/python3.10/site-packages/jupyter_bokeh/widgets.py:91, in BokehModel.update_from_model(self, model)
     89 def update_from_model(self, model):
     90     self._model = model
---> 91     self.render_bundle = self._model_to_traits(model)
     92     self._document.on_change_dispatch_to(self)

File ~/opt/miniconda3/envs/demo-cv2/lib/python3.10/site-packages/jupyter_bokeh/widgets.py:81, in BokehModel._model_to_traits(cls, model)
     79     document = Document()
     80     document.add_root(model)
---> 81 (docs_json, [render_item]) = standalone_docs_json_and_render_items([model], True)
     82 render_bundle = dict(
     83     docs_json=docs_json,
     84     render_items=[render_item.to_json()],
     85     div=div_for_render_item(render_item),
     86 )
     87 return render_bundle

TypeError: standalone_docs_json_and_render_items() takes 1 positional argument but 2 were given``

Screenshots or screencasts of the bug in action

  • I may be interested in making a pull request to address this
@droumis droumis added the TRIAGE Default label for untriaged issues label Feb 10, 2024
@hoxbro
Copy link
Member

hoxbro commented Feb 10, 2024

This is because you have an old version of jupyter_bokeh installed, the latest version of it is 3.0.7, but that does not support Jupyterlab 4 yet, which is why you get the old version.

@droumis
Copy link
Member Author

droumis commented Feb 19, 2024

This should be fixed by bokeh/jupyter_bokeh#196. I'm going to close this since it's not a Panel issue

@droumis droumis closed this as completed Feb 19, 2024
aufdenkampe added a commit to EcohydrologyTeam/ClearWater-riverine that referenced this issue Sep 26, 2024
jupyter_bokeh >=4.0.1 is required for jupyterlab 4 to avoid the error described here: holoviz/panel#6333
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TRIAGE Default label for untriaged issues
Projects
None yet
Development

No branches or pull requests

2 participants