Skip to content

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

Open
@Kontinuation

Description

@Kontinuation

Description

I know that ipywidgets does not render without a kernel and it is expected behavior (see #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: 303cae4)
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions