Skip to content

Widgets do not load if c.LabServerApp.notebook_starts_kernel = False #3980

@lstngr

Description

@lstngr

Description

This issue is adapted from matplotlib/ipympl#593 that I initially opened thinking I was dealing with an ipympl bug.
I'm unfamiliar with widgets, please feel free to let me know if this issue should rather be moved elsewhere.

Widgets do not load if JupyterLab is started with the following configuration,

# cat ~/.jupyter/jupyter_lab_config.py
c = get_config()  #noqa
c.LabServerApp.notebook_starts_kernel = False

In particular, running the documentation's example (the same behavior is observed without calling display),

from IPython.display import display
import ipywidgets as widgets
w = widgets.IntSlider()
display(w)

produces the following output (please note that the kernel disconnected because I shut it down, it otherwise remains running),

Image

and results in the following error in the console,

Image

06:39:41.622 Exception opening new comm 3 jlab_core.a4c5e1f5bac9ba5dc7f6.js:1:1401914
    _handleCommOpen http://localhost:8888/static/lab/jlab_core.a4c5e1f5bac9ba5dc7f6.js?v=a4c5e1f5bac9ba5dc7f6:1

If the jupyterlab configuration is modified such that c.LabServerApp.notebook_starts_kernel = True, the widgets display correctly.

The issue looks similar to #3968, but the browser logs do look different, I believe this is a separate issue.

Reproduce

Starting from a clean conda environment,

conda create -n ipywidgets-test --override-channels --strict-channel-priority -c conda-forge -c anaconda jupyterlab
conda activate ipywidgets-test
pip install --upgrade ipywidgets
  1. Start JupyterLab with c.LabServerApp.notebook_starts_kernel = False in the JupyterLab configuration ~/.jupyter/jupyter_lab_config.py.
  2. Display a widget.

Expected behavior

A slider widget is displayed.

Context

I could reproduce the issue in Firefox 136.0.2 (on Arch Linux), Firefox ESR 128.8.0 (on OpenSUSE Leap 15.6), Chromium 134.0.6998.117 (on OpenSUSE Leap 15.6).

# python -c "import sys; print('\n',sys.version); import ipywidgets; print(ipywidgets.__version__)" && jupyter --version && jupyter labextension list

 3.13.2 | packaged by conda-forge | (main, Feb 17 2025, 14:10:22) [GCC 13.3.0]
8.1.5
Selected Jupyter core packages...
IPython          : 9.0.2
ipykernel        : 6.29.5
ipywidgets       : 8.1.5
jupyter_client   : 8.6.3
jupyter_core     : 5.7.2
jupyter_server   : 2.15.0
jupyterlab       : 4.3.6
nbclient         : 0.10.2
nbconvert        : 7.16.6
nbformat         : 5.10.4
notebook         : not installed
qtconsole        : not installed
traitlets        : 5.14.3
JupyterLab v4.3.6
/home/drscience/miniconda3/envs/ipywidgets-test/share/jupyter/labextensions
        jupyterlab_pygments v0.3.0 enabled OK (python, jupyterlab_pygments)
        @jupyter-widgets/jupyterlab-manager v5.0.13 enabled OK (python, jupyterlab_widgets)

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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy