manzt / anywidget

reusable widgets made easy
https://anywidget.dev
MIT License
510 stars 39 forks source link

Can't use anywidget in latest jupyterlite? #534

Closed bmaranville closed 7 months ago

bmaranville commented 7 months ago

Steps to reproduce:

image

Javascript error:

Error: No version of module anywidget is registered
    loadClass 134.fe2572ece3b7955c89bb.js:1
    loadModelClass 336.0a90bd910629a565bb7e.js:1
    _make_model 336.0a90bd910629a565bb7e.js:1
    new_model 336.0a90bd910629a565bb7e.js:1
    handle_comm_open 336.0a90bd910629a565bb7e.js:1
    _handleCommOpen 134.fe2572ece3b7955c89bb.js:1
    _handleCommOpen 6591.94ed352.js:1
    _handleMessage 6591.94ed352.js:1
    _msgChain 6591.94ed352.js:1
    promise callback*87269/v/this._onWSMessage 6591.94ed352.js:1
    dispatchEvent 1079.cdbaf67.js:1
    dispatchEvent 1079.cdbaf67.js:1
    get 1079.cdbaf67.js:1
    sendMessage 2546.e7c3d46.js:1
    sendMessage 2546.e7c3d46.js:1
    handleComm 2546.e7c3d46.js:1
    _processWorkerMessage kernel.js:128
    onmessage kernel.js:19
    H kernel.js:19
    create index.js:56
    startNew 2546.e7c3d46.js:1
    restart 2546.e7c3d46.js:1
    activate 4931.6e96009.js:1
    route 1245.cbc7a54.js:1
    fetch 1245.cbc7a54.js:1
    handleRequest 6591.94ed352.js:1
    makeRequest 6591.94ed352.js:1
    restartKernel 6591.94ed352.js:1
    restart 6591.94ed352.js:1
    restartKernel 6623.ae3b3cc.js:2
    restart 6623.ae3b3cc.js:2
    execute 4875.375150e.js:1
    execute 8061.cc62561.js:1
    onClick 6623.ae3b3cc.js:2
    onMouseDown 6623.ae3b3cc.js:2
    Be 2287.997c38e.js:2
    Ke 2287.997c38e.js:2
    Pr 2287.997c38e.js:2
    Pr 2287.997c38e.js:2
    Nr 2287.997c38e.js:2
    Rr 2287.997c38e.js:2
    De 2287.997c38e.js:2
    Rr 2287.997c38e.js:2
    Rr 2287.997c38e.js:2
    Zn 2287.997c38e.js:2
    Jn 2287.997c38e.js:2
    unstable_runWithPriority 2287.997c38e.js:2
    Hl 2287.997c38e.js:2
    Me 2287.997c38e.js:2
    Xn 2287.997c38e.js:2
[336.0a90bd910629a565bb7e.js:1:10779](https://jupyter.org/try-jupyter/extensions/@jupyter-widgets/jupyterlab-manager/static/336.0a90bd910629a565bb7e.js?v=0a90bd910629a565bb7e)
manzt commented 7 months ago

Thanks for trying out anywidget. It works in JupyterLite, but it must be installed in JupyterLite distribution (and not within the running notebook). i.e., you can't %pip install anywidget without anywidget already being installed. This is related to #385.

@jtpio has compiled a version of JupyterLite where this is working. You can try it out here. The issue is that the %pip install anywidget command is out of date and needs to be %pip install anywidget==0.9.2 to sync with the correct version the build @jtpio created used.

@jtpio, I wonder if it would be possible to use a CDN-based HTMLManager in JupyterLite, to avoid this issue (and allow users to install different version of anywidget).

bmaranville commented 7 months ago

Thanks! I'll be setting up my own deployment following the example of @jtpio

jtpio commented 7 months ago

I wonder if it would be possible to use a CDN-based HTMLManager in JupyterLite, to avoid this issue (and allow users to install different version of anywidget).

Not sure it's possible at the moment, as it might need something like https://github.com/jupyterlab/jupyterlab/issues/8866, or more generally a way to load plugins from remote places.

manzt commented 7 months ago

Specifically, I was wondering if I could try to swap something alternative to https://github.com/jupyter-widgets/ipywidgets/tree/b78de43e12ff26e4aa16e6e4c6844a7c82a8ee1c/python/jupyterlab_widgets