How to get ipywidgets working in Jupyter Lab?

后端 未结 8 1126
北海茫月
北海茫月 2020-12-07 17:39

In Jupyter Notebook, ipywidgets work fine, however they seem to not work in Jupyter Lab (which is supposedly better than Notebook).

I followed these directions.

8条回答
  •  没有蜡笔的小新
    2020-12-07 18:02

    I have the same issue as @jtlz2 that none of the above suggestion works for me except @hainm's very specific version combination for jupyter-lab, ipywidgests, and jupyter-widgets/jupyterlab-manager.

    Following the initial version numbers listed in this post (https://github.com/jupyter-widgets/ipywidgets/issues/2488#issuecomment-509719214), I tried to find the most updated version combination that works. I list them below, such that one can try it if there is really nothing else working for him/her.

    pythonversion=3.8.0
    labversion=2.1.5
    labmanagerversion=2.0
    ipywidgetsversion=7.5.1
    nodejsversion=10.13.0
    
    conda create -n lab python=$pythonversion -y
    source activate lab
    conda install nodejs=$nodejsversion -c conda-forge -y
    conda install ipywidgets=$ipywidgetsversion -c conda-forge -y
    conda install jupyterlab=$labversion  -y -c conda-forge
    jupyter-labextension install @jupyter-widgets/jupyterlab-manager@$labmanagerversion
    

    It seems that the version of nodejs plays a key role. Holing everything else equal, if I update nodejsversion to 12.x+ or the latest 14.x, this combination as well as @hainm's combination both fail to make ipywidgets behave normally in Jupyterlab.

    Other than the one I listed in the above code cell, below 6 combinations also work for me.

    (pythonversion ,labversion ,labmanagerversion ,ipywidgets ,nodejsversion)

    1. (3.7 , 0.34 , 0.37 , 7.4.2 , 10.13)
    2. (3.7 , 1.0 , 1.0 , 7.4.2 , 10.13)
    3. (3.7 , 2.0 , 2.0 , 7.4.2 , 10.13)
    4. (3.8 , 2.0 , 2.0 , 7.4.2 , 10.13)
    5. (3.8 , 2.0 , 2.0 , 7.5.1 , 10.13)
    6. (3.8 , 2.1.5 , 2.0 , 7.5.1 , 10.13)

提交回复
热议问题