Widgets fail to render Debian 12 J Lab 4.3

Greetings all. I’m new here, instigated by an OS upgrade and migration from notebook to Lab. I have an ipywidgets GUI frontend for the pyEDM · PyPI package, and would like to bring it in compliance with J Lab.

However, a baseline example from the ipywidgets intro docs:

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

does not render the widget, rather a text description:

IntSlider(value=0)

It seems something fundamental is amiss, or perhaps I am incorrectly using the methods.

Thank you!

System Info

~> lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 12 (bookworm)
Release:	12
Codename:	bookworm
~> uname -a
Linux xxx 6.1.0-28-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.119-1 (2024-11-22) x86_64 GNU/Linux

Environment

~> jupyter --version
Selected Jupyter core packages...
IPython          : 8.31.0
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.4
nbclient         : 0.10.2
nbconvert        : 7.16.4
nbformat         : 5.10.4
notebook         : 7.3.2
qtconsole        : 5.6.1
traitlets        : 5.14.3
~> firefox --version
Mozilla Firefox 128.5.0esr

Would downgrading be a workaround? If so, version suggestions? Please. This is preventing progress on use/upgrade of the package UI.

It appears an async _handleCommOpen(msg) request is failing.

Some cookies are misusing the recommended “SameSite“ attribute 62
Language pack 'en_US' not installed! manager.js:49:20
Starting application in workspace: "default" index.js:496:16
Disabling terminals plugin because they are not available on the server index.js:69:16
SyntaxError: JSON.parse: unexpected keyword at line 1 column 1 of the JSON data serverconnection.js:90:24
SyntaxError: JSON.parse: unexpected keyword at line 1 column 1 of the JSON data serverconnection.js:90:24
Starting WebSocket: ws://localhost:8888/api/kernels/7a28b57b-e70f-40c2-bf34-ed3fa3b10da5 default.js:69:20
Starting WebSocket: ws://localhost:8888/api/kernels/7a28b57b-e70f-40c2-bf34-ed3fa3b10da5 default.js:69:20
Starting WebSocket: ws://localhost:8888/api/kernels/7a28b57b-e70f-40c2-bf34-ed3fa3b10da5 default.js:69:20
Exception opening new comm 3 default.js:1124:20
    _handleCommOpen default.js:1124
    _handleMessage default.js:1286
    _msgChain default.js:179
    (Async: promise callback)
    _onWSMessage default.js:176
    (Async: EventHandlerNonNull)
    _createSocket default.js:135
    C default.js:243
    connectTo manager.js:106
    _connectToKernel manager.js:31
    setupKernel default.js:281
    a default.js:46
    connectTo manager.js:96
    startNew manager.js:142
    _changeKernel sessioncontext.js:552
    startKernel sessioncontext.js:334
    _startIfNecessary sessioncontext.js:511
    _initialize sessioncontext.js:450
    initialize sessioncontext.js:418
    _populate context.js:488
    _revert context.js:603
    (Async: promise callback)
    _revert context.js:574
    initialize context.js:204
    c manager.js:551
    (Async: promise callback)
    _createOrOpenDocument manager.js:551
    open manager.js:375
    openOrReveal manager.js:402
    handleOpen listing.js:1305
    evtDblClick listing.js:1514
    handleEvent listing.js:664

The error appears to be in default.js:

    /**
     * Handle a `comm_open` kernel message.
     */
    async _handleCommOpen(msg) {
        this._assertCurrentMessage(msg);
        const content = msg.content;
        const comm = new comm_1.CommHandler(content.target_name, content.comm_id, this, () => {
            this._unregisterComm(content.comm_id);
        });
        this._comms.set(content.comm_id, comm);
        try {
            const target = await Private.loadObject(content.target_name, content.target_module, this._targetRegistry);
            await target(comm, msg);
        }
        catch (e) {
            // Close the comm asynchronously. We cannot block message processing on
            // kernel messages to wait for another kernel message.
            comm.close();
            console.error('Exception opening new comm');
            throw e;
        }
    }

Although I do not know if the preceding terminal & JSON warning are pertinent:

Disabling terminals plugin because they are not available on the server index.js:69:16
SyntaxError: JSON.parse: unexpected keyword at line 1 column 1 of the JSON data serverconnection.js:90:24

Any suggestions/direction for prognosis or progress are appreciated.

Have you tried a hard refresh on the browser page since this update? (Open Jupyter with that test notebook and then do the hard refresh.) Or tried a new browser all together? One you don’t use regularly with Jupyter. It can be hard to be really clear things out when dealing with the browser that ran older code. It can really mislead you.

You can see that probably the issue is inherent in your installation/environment or browser pages using your installation because I bet if you go here and click on the ‘launch binder’ badge to start a new temporary and then run your code in a new notebook, it will work. That is giving JupyterLab 4.4 & not 4.3 right not, but I think that beside the point. I don’t think it is the version that is causing your problem so much as your environment. You should really clean things out before installing the latest if you are making a big jump like it sounds like you did.

For those reasons, I don’t think downgrading is going to help you. But as a workaround you can use a MyBinder-served session or Anaconda Cloud served session to maybe continue development/testing while you sort that environment issue out.

1 Like

@fomightez : Thanks for the suggestions!

This is a clean install of Debian 12, python, Jupyter lab, etc. No previous versions existed. In naiviety I would agree it is likely a system/config issue, but have no clear direction to assess that.

Have you tried a hard refresh on the browser

Yes. Tried:

jupyter lab --NotebookApp.default_url=/lab?reset

Same result. Widgets not rendered.

Or tried a new browser all together?

Yes. Chromium Version 131.0.6778.204 (Official Build) built on Debian GNU/Linux 12 (bookworm) (64-bit)

Same result.

Also disabled ad-blocker. I wondered if the fact that Debian 12 uses Wayland instead X could be an issue… but that seems farfetched.

One distinction is that this is not a system install of python, but a local build of 3.13.1, but it operates flawlessly in all respects.

Maybe you tried what I suggested but you also put jupyter lab --NotebookApp.default_url=/lab?reset just below where you say you tried. I’m not sure that is the same thing. So just checking.

What I meant was:
Like supposedly for Chrome on Linux, when you are on the .ipynb page in Jupyter you’d do: Hold the ⇧ Shift key and press the R key. That is what I referring to for refreshing the page.

But since you tried a different browser, it actually probably won’t help you here.


On the off chance it might help you get ipywidgets working in your case:
Can you try running %pip install ipywidgets in your notebook where you want to run the test. Run that and then restart everything. It will mention the kernel, of course, but that isn’t all that I mean. I mean shutdown and restart the machine, browser, Jupyter. All of it. Then before trying to run the test code refresh the browser page, too. Then try running the test code again in that notebook.

Thanks for the suggestions.

Shift-R seems to toggle the view from cell output below to the side. Perhaps you are referring to restarting the python kernel and clearing all cells? In all cases the result is the same. Since I set the browser to clear cache etc everytime it shuts down, I suspect that satisfies the page refresh criteria.

Also tried %pip install ipywidgets in the notebook. It reports there is nothing to do since it is already installed, and the result is the same.

I would like to understand why this exception is raised:

Exception opening new comm 3 default.js:1124:20
    _handleCommOpen default.js:1124

That seems to be an aspect of the problem.

Sorry. I am not working on a Linux machine so I copied what it said for a refreshing a browser page in chrome from some place. Apparently, it was wrong.

That does seem to indicate part of the issue. But other than letting you know you need to get a good install of everything, I don’t know really what it gets you.
I wonder if it there is a way to force the %pip install ipywidgets? (I know there is a force for conda.) Because even though it says it is installed, it seems all the items have not propagated throughout. Or something is interferring.