jupyter-widgets / tutorial

A tutorial for widgets
BSD 3-Clause "New" or "Revised" License
394 stars 164 forks source link

Extensions build error #118

Open matthhong opened 3 years ago

matthhong commented 3 years ago

While running this command:

jupyter labextension install @jupyter-widgets/jupyterlab-manager @jupyter-widgets/jupyterlab-sidecar bqplot jupyter-threejs jupyter-leaflet@0.12.6 ipysheet ipytree ipycanvas jupyter-matplotlib jupyter-vuetify ipyvolume Check your installation

I get the error:

Building jupyterlab assets (build:prod:minimize) An error occured. RuntimeError: npm dependencies failed to install See the log file for details: /tmp/jupyterlab-debug-anyv5l79.log

The log file has errors of this sort:

> jupyter-matplotlib@0.8.2 build:labextension /home/mih/miniconda3/envs/widgets-tutorial/share/jupyter/lab/staging/node_modules/jupyter-matplotlib
> jupyter labextension build .

Please supply at least one subcommand: check, disable, enable, install, link, list, uninstall, unlink, update
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! jupyter-matplotlib@0.8.2 build:labextension: `jupyter labextension build .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the jupyter-matplotlib@0.8.2 build:labextension script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/mih/.npm/_logs/2021-01-15T18_14_53_268Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! jupyter-matplotlib@0.8.2 build: `webpack && npm run build:labextension`
npm ERR! Exit status 1
npm ERR!

So far I've tried reinstalling node and jupyter within the environment.

jasongrout commented 3 years ago

Looks like the error is in jupyter-matplotlib extension. Can you try just installing that one extension, and if you see the error again, post an issue over in that repo? https://github.com/matplotlib/ipympl

It looks like the current version of jupyter-matplotlib works with the current version of JupyterLab. See the comment below for jupyterlab 2.

jasongrout commented 3 years ago

Actually, if you are using jlab 2, you'll now need to use an older version of jupyter-maplotlib. See https://github.com/matplotlib/ipympl#install-an-old-jupyterlab-extension: jupyter labextension install jupyter-matplotlib@7

jasongrout commented 3 years ago

Since this is a repo for a tutorial at one point in time, the instructions may be out of date at a later point in time, as apparently happened here. Ideally the instructions would be updated to pin all versions as they were when the tutorial was given, or even more ideally, someone will give the tutorial again at some point and update the instructions to current packages.

matthhong commented 3 years ago

@jasongrout I resolved the issue as follows:

Firstly, the environment.yml specifies jlab version 2 for installation. For some reason, the error I specified above shows up when installing extensions with jupyter labextension install ... with jlab 2.

So I used the pip install -r requirements.txt instead, which installs jlab version 3. Which makes the aforementioned error go away!

However, with jlab version 3, readers should SKIP the jupyter labextension install ... part altogether.

I don't know exactly, but it seems like all the extensions are covered by installing jlab 3 through pip. For example, in jlab 3, jupyterlab-manager should be installed with pip install jupyterlab_widgets instead of through labextensions, according to https://www.npmjs.com/package/@jupyter-widgets/jupyterlab-manager. But this isn't even necessary: fetching jupyterlab already fetches all the required extensions.

If readers install all the jupyter labextension install ... stuff additionally on jlab3, they will get errors in their javascript console saying the extensions can't be loaded, and will see a Error displaying widget: model not found error in the cells.

Seems to work! Thank you.

matthhong commented 3 years ago

Realized the above was ambitious - ipyleaflet throws errors on jlab 3 still (I saw on Gitter it was released for jlab 3 just last week?)

Your solution for jlab 2 works perfectly and I was able to finish the tutorial.

martinRenou commented 3 years ago

Firstly, the environment.yml specifies jlab version 2 for installation. For some reason, the error I specified above shows up when installing extensions with jupyter labextension install ... with jlab 2.

ipympl and ipyleaflet broke support for jlab 2, unintentionally. I am actually working on fixing it as I am writing.

ipyleaflet throws errors on jlab 3

This is odd though. Would you mind opening an issue on ipyleaflet showing the steps you followed and which error you had?

matthhong commented 3 years ago

Sounds good

matthhong commented 3 years ago

Never mind Martin, I didn't realize requirements.txt for the tutorial had specified ipyleaflet==0.12.6, so my environment still had the old version.

ipyleaflet==0.13.6 is working fine with the tutorial on jlab 3. Thanks!

martinRenou commented 3 years ago

Good! Happy it works for you

routineCode commented 3 years ago

I thoroughly enjoyed the SciPy 2019 JupyterLab tutorial and was looking forward to going through the SciPy 2019 Widgets tutorial in the same way. But it's strange to me that the 2019 version of the Widgets tutorial is no longer available -- or am I missing something?

It seems I'm forced to use this 2020 version (I find the 2020 video less helpful), and yet when I tried to go through the setup, I saw errors similar to matt1hong. But I didn't want to use the pip solution he mentions because I'm just learning how to work within environments and don't know how to do it outside of conda. I spent hours trying to get set up but never could. The widgets never showed up when I used the notebooks.

Is there any other way I can get those notebooks to work? They look great in the videos, but I'm just not experienced enough to get them working -- which, of course, is why I'm going through tutorials ;)

martinRenou commented 3 years ago

You can still find the 2019 video here: https://www.youtube.com/watch?v=HaSpqsKaRbo&t=5249s. This repository has not changed much since so you can use it while following the video.

JupyterLab 3 came out not so long ago and lots of widgets libraries are not updated. If you stick to JupyterLab 2 and the versions specified here you should be fine.