Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

“Error displaying widget: model not found” with Jupyter lab #112

Closed
MrAnimaniac opened this issue Jul 2, 2019 · 40 comments
Closed

“Error displaying widget: model not found” with Jupyter lab #112

MrAnimaniac opened this issue Jul 2, 2019 · 40 comments

Comments

@MrAnimaniac
Copy link

I followed your installation instructions on a fresh python and jupyter setup with pip but end up with “Error displaying widget: model not found” even if I try to run the provided examples under Jupyter lab.
Nevertheless, the examples run just fine with Jupyter notebook, although I didn’t separately install anything. Is this a known issue?

@SylvainCorlay
Copy link
Member

JupyterLab 1.0 has been released last friday and ipympl does not support it quite yet (although the master branch does). It will be updated in the next day or so.

@russkel
Copy link

russkel commented Jul 3, 2019

I thought I was going mad. What poor timing!

Pip installing the master branch of ipympl didn't work for me. Still getting the same error.

@martinRenou
Copy link
Member

What is the error you are seeing?

@thomasaarholt
Copy link
Contributor

thomasaarholt commented Jul 3, 2019

Same issue here. I've been trying over the past week (as I've been following @martinRenou's updates) but reckoned that it was a WIP bug and that I should wait until it was mostly complete to try.

I installed ipympl on python 3.7.1, latest conda nodejs 11.14.0 and npm 6.7.0, with the following commands:

git clone repo
pip install .
jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter labextension install jupyter-matplotlib

I then test it with

%matplotlib widget
import matplotlib.pyplot as plt
plt.figure()
plt.plot([1,2,3])

I'm happy to debug more.

Edit:
I've also tried calling the
jupyter nbextension install --py --symlink --sys-prefix ipympl and jupyter nbextension enable --py --sys-prefix ipympl commands just to be sure.

I decided not to follow through with the full readme.md developer install instructions, since I don't want to develop it, just test the most recent version. If this is where I have gone wrong, it would be great if someone could clarify why the above doesn't work :)

@thomasaarholt
Copy link
Contributor

I would try in a fresh conda environment, but I have terrible internet until tomorrow.

@martinRenou
Copy link
Member

martinRenou commented Jul 3, 2019

If you are installing a dev version, instead of

jupyter labextension install jupyter-matplotlib

(I suggest you uninstall it with jupyter labextension uninstall jupyter-matplotlib)

you should try from the jupyter-matplotlib directory:

jupyter labextension install js

@thomasaarholt
Copy link
Contributor

$ jupyter labextension install js
An error occured.
ValueError: "/home/thomasaar/documents/jupyter-matplotlib/js" is not a valid npm package
See the log file for details:  /tmp/jupyterlab-debug-q6xjcr43.log

@thomasaarholt
Copy link
Contributor

Here is the log:
Uploading jupyterlab-debug-q6xjcr43.log…

@thomasaarholt
Copy link
Contributor

(I am going to be a bit on and off wifi today, catching a ferry in a few hours and then a plane during the night)

@martinRenou
Copy link
Member

Are you sure you are in the right directory? Is there a js directory in the current location? What does ls say?

@thomasaarholt
Copy link
Contributor

Yes, definitely right directory:

$ ls
environment.yml  ipympl           js                       LICENSE      matplotlib.gif  RELEASE.md  setup.py
examples         ipympl.egg-info  jupyter-matplotlib.json  MANIFEST.in  README.md       setup.cfg

@thomasaarholt
Copy link
Contributor

I'm gonna suggest that we wait with debugging my case until I can make a fresh conda environment. Meanwhile, maybe @MrAnimaniac or @russkel have tried as well?

@thomasaarholt
Copy link
Contributor

@martinRenou is there a specific npm/nodejs version requirement? #57 suggests there was, but i suspect that is old news?

@martinRenou
Copy link
Member

Not that I know of, I have nodejs 11.14.0 installed with conda, and it seems to work just fine

@t1nux
Copy link

t1nux commented Jul 3, 2019

I am facing the same error as well. In order to reproduce the error, I'm simply using docker where I am installing everything via pip. Maybe this will help reproduce the error (and help fix it).

Dockerfile

FROM python:3.7
WORKDIR /jup
COPY . /jup
RUN apt-get update \
	&& curl -sL https://deb.nodesource.com/setup_12.x | bash - \
	&& apt-get install -y nodejs \
	&& pip install --trusted-host pypi.python.org -r python_requirements.txt \
	&& jupyter labextension install @jupyter-widgets/jupyterlab-manager \
	&& jupyter labextension install jupyter-matplotlib \
	&& jupyter labextension install jupyterlab_bokeh
EXPOSE 8888
ENTRYPOINT ["jupyter", "lab","--ip=0.0.0.0","--allow-root"]

python_requirements.txt

numpy
scipy
pandas
sympy
jupyterlab
matplotlib
bokeh
ipympl

I am building the docker image with: docker build -t img/jupyterlab:test01 .
And I am running it with: docker run -p 8888:8888 img/jupyterlab:test01

The code to test is:

%matplotlib widget
import matplotlib.pyplot as plt
plt.plot([0, 1, 2])

which results in: Error displaying widget: model not found

@martinRenou
Copy link
Member

If you are using jupyterlab 1.0 it cannot work, it should work on master though. Please wait for a release of jupyter-matplotlib before using jupyterlab 1.0

@thomasaarholt
Copy link
Contributor

:D

I misinterpreted @SylvainCorley's comment above as the master of ipympl should work with jupyterlab 1.0, rather than the opposite.

That makes sense, and probably explains the error. Does it work with the most recent non 1.0 of jupyterlab?

@martinRenou
Copy link
Member

I misinterpreted @SylvainCorley's comment above as the master of ipympl should work with jupyterlab 1.0, rather than the opposite.

You did not misinterpret Sylvain's answer. The master of ipympl works with jupyterlab 1.0.

But if you use the last released version of ipympl with JupyterLab 1.0, it does not work. We need to release ipympl first.

@russkel
Copy link

russkel commented Jul 4, 2019

I am running in a pipenv on 3.7.3, I uninstalled the labextension, pip uninstalled ipympl then
pip install git+https://github.com/matplotlib/jupyter-matplotlib.git#egg=ipympl and then rebuilt extensions. Running the code as per @t1nux 's post returns the same error, and in the terminal I get this:

[IPKernelApp] WARNING | No such comm: d87b30d7f6b54fcc88683fa792c98baf
[IPKernelApp] WARNING | No such comm: 6ab177c9e2c34633965a94a9b100f4a2

@ivartz
Copy link

ivartz commented Jul 4, 2019

I got all examples in https://github.com/matplotlib/jupyter-matplotlib/blob/master/examples/ipympl.ipynb working after running:

jupyter labextension uninstall jupyter-matplotlib && jupyter labextension uninstall @jupyter-widgets/jupyterlab-manager && conda update -y widgetsnbextension && conda update -y nodejs && pip uninstall -y ipympl && pip install git+https://github.com/matplotlib/jupyter-matplotlib.git#egg=ipympl && conda update jupyterlab -y && jupyter labextension install @jupyter-widgets/jupyterlab-manager && jupyter labextension install jupyter-matplotlib && jupyter labextension update --all && jupyter lab build && jupyter nbextension list && jupyter labextension list

From what I understand, the important combination is the master ipympl from github (0.3.1) + latest jupyterlab conda install (1.0.1). Also made sure other important packages were updated, and finally all jupyterlab extension updated and rebuilt. At last a verification that all jupyter nbextensions and labextensions were ok.

@SylvainCorlay
Copy link
Member

We just release 0.3.1 with support for jupyterlab 1.0.

@StanczakDominik
Copy link

I'd just like to, one, confirm that 0.3.1 fixes the issue, and two, thank everyone involved for solving this :)

@russkel
Copy link

russkel commented Jul 5, 2019

Working a treat now. I think the issue was even with the master ipympl, jupyter-matplotlib v0.3.0 was being installed into jupyter directory. Maybe something to check out?

@SylvainCorlay
Copy link
Member

Thanks. Closing.

@gabegrand
Copy link

I was getting the same error. Followed the steps from @ivartz above and can confirm that widgets display properly now. Thanks everyone!

@westurner
Copy link

westurner commented Jul 9, 2019

@SylvainCorlay What were the changes necessary to support JupyterLab 1.0?
Are there JupyterLab docs on what needs to be upgraded?

(edit)

@davzaman
Copy link

davzaman commented Sep 6, 2019

For background I had done the following:

conda install -c conda-forge ipympl
conda install nodejs
jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter labextension install jupyter-matplotlib
jupyter labextension install ipyvolume

And got issues, so I ran: conda update jupyterlab && jupyter labextension update --all and it fixed.

@jbulow
Copy link

jbulow commented Nov 12, 2019

This is still an issue with jupyter lab 1.2.2 and current jupter-matplotlib

@martinRenou
Copy link
Member

@jbulow it's not, you must have missed a step in the installation. Please check that you correctly followed the installation steps. Did you correctly install the JupyterLab extensions?

jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyter-matplotlib

@RGD2
Copy link

RGD2 commented Nov 29, 2019

I am having the same issue. Also:

root@vagrant:~# jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyter-matplotlib
Building jupyterlab assets (build:prod:minimize)
An error occured.
RuntimeError: JupyterLab failed to build
See the log file for details:  /tmp/jupyterlab-debug-57792pd3.log
root@vagrant:~# jupyter labextension list
JupyterLab v1.2.1
Known labextensions:
   app dir: /usr/local/share/jupyter/lab
        @jupyter-widgets/jupyterlab-manager v1.1.0  enabled  OK
        @jupyterlab/git v0.8.2  enabled  OK
        @jupyterlab/toc v1.0.1  enabled  OK
        @krassowski/jupyterlab_go_to_definition v0.7.1  enabled  OK
        @lckr/jupyterlab_variableinspector v0.3.0  enabled  OK
        @ryantam626/jupyterlab_sublime v0.2.0  enabled  OK
        jupyter-matplotlib v0.4.2  enabled  OK
        jupyterlab-drawio v0.6.0  enabled  OK
        nbdime-jupyterlab v1.0.0  enabled  OK
root@vagrant:~# pip show ipywidgets
Name: ipywidgets
Version: 7.5.1
Summary: IPython HTML widgets for Jupyter
Home-page: http://ipython.org
Author: IPython Development Team
Author-email: ipython-dev@scipy.org
License: BSD
Location: /usr/local/lib/python3.7/dist-packages
Requires: ipykernel, traitlets, ipython, widgetsnbextension, nbformat
Required-by: ipympl

Funny thing was, I had this working... until I added a different extension (which triggered a rebuild). After which, it broke. This is running in a VM with 1GB ram. I will try upping the memory and see if that fixes the problem. (might be the minimize part of the build running out of ram - I do see swapfile use).
That logfile ended in:

> node /usr/local/lib/python3.7/dist-packages/jupyterlab/staging/yarn.js run build:prod:minimize
yarn run v1.15.2
$ ensure-max-old-space webpack --config webpack.prod.minimize.config.js
child_process.js:642
    throw err;
    ^

Error: Command failed: webpack --config webpack.prod.minimize.config.js
    at checkExecSyncError (child_process.js:621:11)
    at Object.execFileSync (child_process.js:639:15)
    at Object.<anonymous> (/usr/local/share/jupyter/lab/staging/node_modules/@jupyterlab/buildutils/lib/ensure-max-old-space.js:30:17)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10)
    at internal/main/run_main_module.js:17:11 {
  status: null,
  signal: 'SIGKILL',
  output: [ null, null, null ],
  pid: 1320,
  stdout: null,
  stderr: null
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

JupyterLab failed to build
Traceback (most recent call last):

  File "/usr/local/lib/python3.7/dist-packages/jupyterlab/debuglog.py", line 47, in debug_logging
    yield

  File "/usr/local/lib/python3.7/dist-packages/jupyterlab/labextensions.py", line 105, in start
    command=command, app_options=app_options)

  File "/usr/local/lib/python3.7/dist-packages/jupyterlab/commands.py", line 459, in build
    command=command, clean_staging=clean_staging)

  File "/usr/local/lib/python3.7/dist-packages/jupyterlab/commands.py", line 669, in build
    raise RuntimeError(msg)

RuntimeError: JupyterLab failed to build

Exiting application: jupyter

It seems like the gui-managed rebuild process sometimes silently fails this way during the rebuild of jupyter-matplotlib, leaving the widget javascript missing.

I'll see if throwing more memory at it helps (was using the default vagrant config which was only 1GB). BTW I am bulding within a singularity image, on a vagrant managed virtualbox VM on windows.
The exact fork is at https://github.com/RGD2/jupyter/tree/pipjupyterlab which works, (with working matplot lib) but with wierd steps which involve repeated builds and refreshs (see the commit message for those steps).

@RGD2
Copy link

RGD2 commented Nov 29, 2019

4GB ram seems to fix my problem with jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyter-matplotlib failing, but I still have the error in the title of this issue.
(good to know if you're trying to install this on a raspi or other linux SBC -- probably will need the 4GB ram model).

@minostauros
Copy link

Since I avoid using Conda, I tried following:

In my case, just worked with

jupyter labextension update --all 
jupyter lab build 
jupyter nbextension list
jupyter labextension list

which comes after installation process of

pip install jupyterlab
pip install ipympl
curl -sL https://deb.nodesource.com/setup_12.x | bash -
apt install nodejs
jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter labextension install jupyter-matplotlib

@belletbg
Copy link

belletbg commented Oct 6, 2020

I followed your installation instructions on a fresh python and jupyter setup with pip but end up with “Error displaying widget: model not found” even if I try to run the provided examples under Jupyter lab.
Nevertheless, the examples run just fine with Jupyter notebook, although I didn’t separately install anything. Is this a known issue?

yes, runs fine in notebook

@ray-ronnaret
Copy link

Today I still have the same problem after update to Jupyter lab 3. I would appreciate for the suggestions.

@martinRenou
Copy link
Member

Please open another issue with your specific problem and show us the output of the requested commands when opening an issue.

@shnaqvi
Copy link

shnaqvi commented Mar 13, 2021

@ray-ronnaret , I ran into the same issue and I'm in the same boat as @minostauros, who prefers brew over conda to manage packages on my macOS Big Sur. @minostauros's super-helpful advice worked for me! And listed below are the 2 changes I made:

  1. One major change for JupyterLab 3.0 was to install the jupyter-widgets/jupyterlab-manager using pip instead of jupyter labextension install by following the instructions here:
pip install ipywidgets --upgrade
  1. Another change for me was to use brew to install nodejs:
brew install node

Finally, ensured that all extensions are enabled, OK and compatible by running:

jupyter labextension update --all 
jupyter labextension list

In Summary, here's the full trail of commands:

pip install jupyterlab --upgrade
pip install ipympl --upgrade

brew install node
pip install ipywidgets --upgrade

jupyter labextension install jupyter-matplotlib

jupyter labextension update --all 
jupyter lab build 
jupyter labextension list

As a bonus, I also enabled using plotly with:

jupyter labextension install jupyterlab-plotly

Note:

  • Uninstall any extensions listed as incompatible by jupyter labextension list, by calling jupyter labextension uninstall <extension-name>. In my case @jupyter-widgets/jupyterlab-managerandjs` were being shown as incompatible.
  • Check that you indeed have JupyterLab 3.0 installed using pip show jupyterlab

@ianhi
Copy link
Collaborator

ianhi commented Mar 13, 2021

@shnaqvi You should not need to to labextension install anymore. In fact I'd advise against doing that jupyter-matplotlib instead let the pip install handle everything. For an ipympl only installation (in a fresh virtual environment) the only step that should be necessary is:

pip install --upgrade jupyterlab ipympl

@gwerbin-tive
Copy link

@shnaqvi You should not need to to labextension install anymore. In fact I'd advise against doing that jupyter-matplotlib instead let the pip install handle everything. For an ipympl only installation (in a fresh virtual environment) the only step that should be necessary is:

pip install --upgrade jupyterlab ipympl

What if I need to run Jupyterlab from a different environment than my IPython kernel? Or is that not a supported use case?

@fmgonsalves
Copy link

I've got the same question. I have JupyterLab installed on a common/"master" environment. I have various environments created according to the application needs and each one having its own ipykernel. I have even installed ipympl in each environment - not sure if this is necessary.

When I run JupyterLab from the master environment, create a new notebook using one of the other environments and try to plot a figure, I have the same error as the OP.

@thomasaarholt
Copy link
Contributor

Please create a new issue on this topic, even though you get the same error :) There are 20 people getting pinged with each new comment here, and many of them do not use jupyterlab via nb_kernels.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests