ipywidgets icon indicating copy to clipboard operation
ipywidgets copied to clipboard

Widgets cannot be displayed when the notebook is opened with no kernel attached, even after we attach the notebook to an ipykernel.

Open Kontinuation opened this issue 10 months ago • 0 comments
trafficstars

Description

I know that ipywidgets does not render without a kernel and it is expected behavior (see https://github.com/jupyter-widgets/ipywidgets/issues/3773). However, after I attach ipywidget to the notebook and run cells that produces widgets, the widgets still does not show up.

Reproduce

Launch the jupyter lab using the following command:

jupyter lab --LabServerApp.notebook_starts_kernel=False

The --LabServerApp.notebook_starts_kernel=False option makes new notebooks being opened in "No Kernel" state. When you run a cell, Jupyter Lab will open a dialog asking you to select a kernel. We select "ipykernel" to run the cells, but the widgets produced by the cell does not show up.

Here is a screen recording of a repro: https://drive.google.com/file/d/1EHGwKnv7ehDmMGw_AC4VAnseUprJPAcl/view?usp=sharing

Expected behavior

After attaching the notebook to ipykernel, newly produced widgets could show up.

Context

  • ipywidgets version: latest main branch (commit: https://github.com/jupyter-widgets/ipywidgets/commit/303cae4dc268640a01ce08bf6e22da6c5cd201e4)
  • Operating System and version: macOS 15.2
  • Browser and version: Chrome Version 131.0.6778.265 (Official Build) (arm64)
Browser Output
plugin.ts:153 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'kernel')
    at getWidgetManagerOwner (plugin.ts:153:34)
    at async registerWidgetHandler (plugin.ts:175:25)
    at async plugin.ts:424:7

If using JupyterLab

  • JupyterLab version: 4.3.3
Installed Labextensions
jupyter_spark_ui v0.1.0 enabled OK (python, jupyter_spark_ui)
jupyterlab_pygments v0.3.0 enabled OK (python, jupyterlab_pygments)
sparkmonitor v3.0.2 enabled OK (python, sparkmonitor)
@jupyter-notebook/lab-extension v7.3.1 enabled OK
@jupyter-widgets/jupyterlab-manager v5.0.13 enabled OK

Kontinuation avatar Jan 17 '25 10:01 Kontinuation