Skip to content

VS Code: RuntimeError: Models must be owned by only a single document #8263

@MarcSkovMadsen

Description

@MarcSkovMadsen

panel==1.8.2

Reproduce

In VS Code

  1. Open the notebook test_panel.ipynb
Image
  1. Click Run All
  2. Drag the slider in cell output 3
    Observe the exception
Image
2025-10-24 18:31:21,801 ERROR: panel.reactive - Callback failed for object named '' changing property {'value': 2} 
Traceback (most recent call last):
  File "/home/jovyan/.local/lib/python3.12/site-packages/panel/reactive.py", line 476, in _process_events
    self.param.update(**self_params)
  File "/home/jovyan/.local/lib/python3.12/site-packages/param/parameterized.py", line 2406, in update
    restore = dict(self_._update(arg, **kwargs))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/.local/lib/python3.12/site-packages/param/parameterized.py", line 2439, in _update
    self_._batch_call_watchers()
  File "/home/jovyan/.local/lib/python3.12/site-packages/param/parameterized.py", line 2624, in _batch_call_watchers
    self_._execute_watcher(watcher, events)
  File "/home/jovyan/.local/lib/python3.12/site-packages/param/parameterized.py", line 2586, in _execute_watcher
    watcher.fn(*args, **kwargs)
  File "/home/jovyan/.local/lib/python3.12/site-packages/panel/param.py", line 945, in _replace_pane
    self._update_inner(new_object)
  File "/home/jovyan/.local/lib/python3.12/site-packages/panel/pane/base.py", line 742, in _update_inner
    new_pane, internal = self._update_from_object(
                         ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jovyan/.local/lib/python3.12/site-packages/panel/pane/base.py", line 731, in _update_from_object
    old_object.object = object
    ^^^^^^^^^^^^^^^^^
  File "/home/jovyan/.local/lib/python3.12/site-packages/param/parameterized.py", line 515, in _f
    instance_param.__set__(obj, val)
  File "/home/jovyan/.local/lib/python3.12/site-packages/param/parameterized.py", line 517, in _f
    return f(self, obj, val)
...
    ma._attach_document(document)
  File "/home/jovyan/.local/lib/python3.12/site-packages/bokeh/model/model.py", line 596, in _attach_document
    raise RuntimeError(f"Models must be owned by only a single document, {self!r} is already in a doc")
RuntimeError: Models must be owned by only a single document, ImportedStyleSheet(id='c72f79d1-b9f8-441d-a42d-05f054dcee14', ...) is already in a doc
Output is truncated. View as a [scrollable element](command:cellOutput.enableScrolling?03a61af8-3dc8-43ea-9ec5-1c49ab50aa52) or open in a [text editor](command:workbench.action.openLargeOutput?03a61af8-3dc8-43ea-9ec5-1c49ab50aa52). Adjust cell output [settings](command:workbench.action.openSettings?%5B%22%40tag%3AnotebookOutputLayout%22%5D)...
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File /opt/conda/lib/python3.12/site-packages/jupyter_bokeh/widgets.py:149, in BokehModel._sync_model(self, _model, content, _buffers)
    147 new = descriptor.property.prepare_value(model, descriptor.name, new)
    148 old = descriptor._get(model)
--> 149 descriptor._set(model, old, new, setter=setter)
    151 for cb in model._callbacks.get(attr, []):
    152     cb(attr, old, new)

File ~/.local/lib/python3.12/site-packages/bokeh/core/property/descriptors.py:614, in PropertyDescriptor._set(self, obj, old, value, hint, setter)
    611     self._set_value(obj, value)
    613 # for notification purposes, "old" should be the logical old
--> 614 self._trigger(obj, old, value, hint=hint, setter=setter)

File ~/.local/lib/python3.12/site-packages/bokeh/core/property/descriptors.py:692, in PropertyDescriptor._trigger(self, obj, old, value, hint, setter)
    655 """ Unconditionally send a change event notification for the property.
    656 
    657 Args:
   (...)    689 
    690 """
    691 if hasattr(obj, 'trigger'):
--> 692     obj.trigger(self.name, old, value, hint, setter)

File ~/.local/lib/python3.12/site-packages/bokeh/model/model.py:583, in Model.trigger(self, attr, old, new, hint, setter)
    581 # chain up to invoke callbacks
...
--> 596     raise RuntimeError(f"Models must be owned by only a single document, {self!r} is already in a doc")
    598 doc.theme.apply_to_model(self)
    599 self.document = doc

RuntimeError: Models must be owned by only a single document, ImportedStyleSheet(id='c72f79d1-b9f8-441d-a42d-05f054dcee14', ...) is already in a doc

Additional Context

  1. If I execute the first 3 cells individually and then drag the slider no issue.
  2. If I run this in Jupyter lab there is no issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: ipywidgetRelated to rendering IPyWidgets or rendering Panel components as IPyWidgets

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions