jupyter-widgets / ipywidgets

Interactive Widgets for the Jupyter Notebook
https://ipywidgets.readthedocs.io
BSD 3-Clause "New" or "Revised" License
3.17k stars 949 forks source link

Install on JupyterLab v2.2.8 gives "Error displaying widget: model not found" #2989

Open adamgit opened 4 years ago

adamgit commented 4 years ago

I followed all the install instructions as per current docs:

(NB the main install instructions are missing the pip command for nodejs - inconsistent with the first half of the page)

  1. ~$ pip3 install ipywidgets Requirement already satisfied: ipywidgets in /usr/lib/python3/dist-packages (6.0.0)

  2. ~$ jupyter labextension list

    JupyterLab v2.2.8
    Known labextensions:
    app dir: /home/ubuntu/.local/share/jupyter/lab
        @jupyter-widgets/jupyterlab-manager v2.0.0  enabled  OK
  3. ~$ pip3 install nodejs

    Collecting nodejs
    Downloading nodejs-0.1.1.tar.gz (2.3 kB)
    Collecting optional-django==0.1.0
    Downloading optional-django-0.1.0.tar.gz (9.5 kB)
    Building wheels for collected packages: nodejs, optional-django
    Building wheel for nodejs (setup.py) ... done
    Created wheel for nodejs: filename=nodejs-0.1.1-py3-none-any.whl size=3492 sha256=946d522b2e779ff12eb0e519454dde8112e245c7beae02f440af9b41d454ef09
    Stored in directory: /home/ubuntu/.cache/pip/wheels/b3/ce/d8/40f8634e964582985b2c4560cbba06d4f50d3da980fccd0497
    Building wheel for optional-django (setup.py) ... done
    Created wheel for optional-django: filename=optional_django-0.1.0-py3-none-any.whl size=9980 sha256=639211f5ebee16fc28459f48ac5ebe61f2555c88ce7d6e95b85258d03954265a
    Stored in directory: /home/ubuntu/.cache/pip/wheels/3b/42/9c/10c5c4021a4edf8416f18e88b427b92e99f187e61e15e08100
    Successfully built nodejs optional-django
    Installing collected packages: optional-django, nodejs
    Successfully installed nodejs-0.1.1 optional-django-0.1.0

After restarting jupyter-lab and running a simple example from the docs:

import ipywidgets as widgets
widgets.IntSlider()

It fails with:

Widget Javascript not detected.  It may not be installed or enabled properly.
Error displaying widget: model not found

NB: I disabled all ad-blockers and globally enabled all javascript.

ianhi commented 4 years ago

(NB the main install instructions are missing the pip command for nodejs - inconsistent with the first half of the page)

This is because pip install nodejsand conda install nodejs do different things. pip install nodejs will install this outdated python package: https://github.com/markfinger/python-nodejs conda on the other hand manages more than just python installs, so conda install nodejs will install https://nodejs.org/en/ which is necessary for jupyterlab extensions to work. You can also install nodejs via the instructions on the nodejs website.

Can you paste the output from running jupyter lab build? As well can you check if there is any output in the javascript console (https://balsamiq.com/support/faqs/browserconsole/)?

Another important troubleshooting step is to refresh the browser page after you run jupyterlab build.