Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly is the purpose of the JupyterLab extension of ipywidgets?

According to this: https://ipywidgets.readthedocs.io/en/stable/user_install.html , in order to use ipywidgets on a legacy Jupyter Notebook, one has to install the appropriate Jupyter Notebook extension like this:

pip install ipywidgets
jupyter nbextension enable --py widgetsnbextension

Moreover, in order to use ipywidgets from a Notebook that runs through JupyterLab, one was to install the JupyterLab extension of ipywidgets using:

jupyter labextension install @jupyter-widgets/jupyterlab-manager

Why is that the case? I was under the impression that the Notebook of JupyterLab is just a legacy Jupyter Notebook that is packed as an extension of JupyterLab. I tried to read through the code of the ipywidgets JupyterLab extension but I am not sure what is going on.

I would appreciate if someone could list the most important reasons as to why installing just the Jupyter Notebook extension of ipywidgets is not enough when running Notebooks through JupyterLab.

Thanks in advance.

like image 276
AstrOne Avatar asked Oct 19 '25 10:10

AstrOne


2 Answers

So I guess the point of running either the nbextension or the labextension script is to add some new CSS and Javascript libraries; presumably the paths etc are different for jupyterlab vs vanilla jupyter; I don't think there's any reason to expect that nbextensions will be shared with jupyter lab.

like image 157
maxymoo Avatar answered Oct 22 '25 03:10

maxymoo


The notebook of jupyter lab is not just the legacy notebook packed into jupyter lab. An extension that runs as an nbextension does not automatically work as a labextension, and vis versa, because the extension api is different. Thus for an extension to work in both environments the authors of extensions have to write two versions of the extension (although if done with care the vast majority of the code can be the same, only the portion that interfaces with the lab notebook api, or legacy notebook api, needs to differ). See this stackoverflow answer for additional insights.

like image 31
Daniel Goldfarb Avatar answered Oct 22 '25 03:10

Daniel Goldfarb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!