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

[Bug][Jupyter Widget] Error displaying widget: model not found #1064

Closed
JackKelly opened this issue Apr 7, 2020 · 16 comments
Closed

[Bug][Jupyter Widget] Error displaying widget: model not found #1064

JackKelly opened this issue Apr 7, 2020 · 16 comments
Assignees
Labels
jupyter keplergl for Jupyter

Comments

@JackKelly
Copy link

JackKelly commented Apr 7, 2020

Describe the bug
Attempting to display a map in JupyterLab 2.1.0 prints an error within Jupyter Lab: "Error displaying widget: model not found"

My guess (but I really am guessing!) is that the keplergl widget needs to be updated to play nicely with JupyterLab 2.1.0. (Or maybe I'm doing something stupid! This is the first time I've tried installing the keplergl widget!)

To Reproduce

Installation:

conda config --add channels conda-forge
conda create --name test_kepler python=3.8 jupyterlab ipywidgets nodejs
conda activate test_kepler
pip install keplergl
jupyter labextension install @jupyter-widgets/jupyterlab-manager keplergl-jupyter
jupyter lab

Create a new notebook and run:

from keplergl import KeplerGl
map_1 = KeplerGl()
map_1

Output:

User Guide: https://github.com/keplergl/kepler.gl/blob/master/docs/keplergl-jupyter/user-guide.md
Error displaying widget: model not found

Expected behavior
A map should be displayed :)

Environment:

  • conda virtual environment
  • Python version: 3.8.2
  • keplergl Widget version 0.1.2
  • jupyterlab 2.1.0
  • ipywidgets 7.5.1

jupyter labextension list

JupyterLab v2.1.0
Known labextensions:
   app dir: /home/jack/miniconda3/share/jupyter/lab
        @jupyter-widgets/jupyterlab-manager v2.0.0  enabled  OK
        jupyterlab-plotly v4.6.0  enabled  OK
        keplergl-jupyter v0.1.2  enabled  OK

Bug reports in other projects
Here are issues in other projects where users report seeing the "Error displaying widget: model not found" issue:

@JackKelly JackKelly added the jupyter keplergl for Jupyter label Apr 7, 2020
@JackKelly
Copy link
Author

JackKelly commented Apr 9, 2020

A work-around in kepler's Jupyter widget:

from keplergl import KeplerGl
map_1 = KeplerGl()
map_1.save_to_html()

And then open keplergl_map.html in a browser. (And it looks gorgeous!)

BTW, pydeck also suffers from the same problem: Running deck.show() in a Jupyter Lab cell returns Error displaying widget: model not found. A work-around in pydeck is to run deck.to_html() and load the html in a browser.

@akelai
Copy link

akelai commented Apr 17, 2020

@JackKelly your work-around does not take advantage of Kepler.gl feature to render the interactive widget inside the notebook, allowing to edit it, and then save the notebook (taking care of having "Settings -> Save Widget State Automatically") to save the state of the Kepler-gl widget: then use e.g. "map_1.config" to get the saved config from it, that could be saved as a file (that could be used as an input config when creating the widget itself, so to allow easy editing of the kepler.gl map, and as a last action do a "save_to_html" to create the final file).

Anyway, trying (but not succeeding) to solve your same problem (that is also reported by others, and is an outstanding problem) I can report this:

Besides your installation steps, I've also done these actions:

jupyter nbextension install --py --sys-prefix keplergl
jupyter nbextension enable --py --sys-prefix keplergl

...and then in JupyterLab:
Settings -> Enable Extension Manager (experimental)

I'm not sure which action triggered a different behaviour than the "Error displaying widget: model not found", but now when trying to display the widget with:

map_1 = KeplerGl()
map_1

...I get this instead:

User Guide: https://github.com/keplergl/kepler.gl/blob/master/docs/keplergl-jupyter/user-guide.md
Loading widget...

...but actually the widget never shows up. The kernel works (filled circle) and then it goes back to unused state (empty circle), and I can keep using the notebook normally, but instead of the interactive kepler.gl widget I just have that "Loading widget..." text.

@cameronkruse
Copy link

I'm getting this as well. So far no luck with updating or any other trouble shooting.

@arcrank
Copy link

arcrank commented Apr 29, 2020

I am getting same errors. This wasn't happening a few weeks ago, I tried with new env and still no luck.

@firasm
Copy link

firasm commented May 9, 2020

Any updates on this? perhaps the best way is to downgrade Jupyterlab? Can anyone let me know the last jupyterlab version that this worked with?

@heshan0131
Copy link
Contributor

Upgrade widget to kepler.gl@^2 and supporting JupyterLab 2
#1110

@heshan0131
Copy link
Contributor

just published keplergl==0.2.0 with support for JupyterLab 2.0

@firasm
Copy link

firasm commented May 13, 2020

I am now able to get this working in jupyter lab 2.1.2!! Hooray! Thanks @heshan0131

For future reference here are my versions:

jupyter --version

jupyter core     : 4.6.3
jupyter-notebook : 6.0.3
qtconsole        : 4.7.3
ipython          : 7.14.0
ipykernel        : 5.2.1
jupyter client   : 6.1.3
jupyter lab      : 2.1.2
nbconvert        : 5.6.1
ipywidgets       : 7.5.1
nbformat         : 5.0.6
traitlets        : 4.3.3

Node version:
node v10.20.1

@akelai
Copy link

akelai commented May 13, 2020

No success here.
Here's what I've done:

jupyter labextension update @jupyter-widgets/jupyterlab-manager keplergl-jupyter

After this command, the automatic build of JupyterLab started and failed, so I've done:

export NODE_OPTIONS=--max-old-space-size=4096
jupyter lab build

...and the build completed successfully.
Then in JupyterLab I've tried with:

from keplergl import KeplerGl
map_1 = KeplerGl()
map_1

...but I've got the same behavior as before (the "Loading widget..." message, without actually showing the widget).

These are my versions:
jupyter --version

jupyter core     : 4.6.3
jupyter-notebook : 6.0.3
qtconsole        : 4.7.1
ipython          : 7.13.0
ipykernel        : 5.1.4
jupyter client   : 6.0.0
jupyter lab      : 2.0.1
nbconvert        : 5.6.1
ipywidgets       : 7.5.1
nbformat         : 5.0.4
traitlets        : 4.3.3

@firasm
Copy link

firasm commented May 13, 2020

You can try my instructions here: https://github.com/firasm/keplergl_tutorial/blob/master/1%20-%20Install/Installation%20instructions.ipynb.

You may need to also run

jupyter labextension install keplergl-jupyter
and
jupyter labextension enable keplergl-jupyter

P.S. I'd also encourage you to update jupyter to 2.1.2 (pip install jupyter --upgrade) just in case something changed on their side

@akelai
Copy link

akelai commented May 14, 2020

Thank you for your kind help @firasm
Though, I haven't solved the problem.
I've done the following:

jupyter labextension install keplergl-jupyter
jupyter labextension enable keplergl-jupyter
conda update -c conda-forge jupyterlab
export NODE_OPTIONS=--max-old-space-size=4096
jupyter lab build

So now I have:
jupyter --version

jupyter core     : 4.6.3
jupyter-notebook : 6.0.3
qtconsole        : 4.7.4
ipython          : 7.14.0
ipykernel        : 5.2.1
jupyter client   : 6.1.3
jupyter lab      : 2.1.2
nbconvert        : 5.6.1
ipywidgets       : 7.5.1
nbformat         : 5.0.6
traitlets        : 4.3.3

Oh, maybe this is useful to highlight: I see from Chrome developer console this problem when I open a .ipynb file that uses Kepler.gl:

_manager-base.js:274_
Could not instantiate widget

_manager.js:319_
Uncaught (in promise) Error: Module keplergl-jupyter, semver range ^0.1.0 is not registered as a widget module

@firasm
Copy link

firasm commented May 14, 2020

Ah, it seems your keplergl widget version is old. You’ll need the latest one that was released yesterday:

pip install keplergl —upgrade

@akelai
Copy link

akelai commented May 14, 2020

Thanks @firasm, I thought I had upgraded to the latest one relased yesterday, but probably I did it in a wrong way... because well, after a pip install keplergl --upgrade, now it is working, the keplergl map is shown into JupyterLab.

Though, in Chrome developer console, I still get that error:

_manager-base.js:274_
Could not instantiate widget

_manager.js:319_
Uncaught (in promise) Error: Module keplergl-jupyter, semver range ^0.1.0 is not registered as a widget module

I'm curious if I'm the only one now with a working keplergl widget in JupyterLab 2, who gets that error in console, or it's a normal thing.

Regardless of that, anyway, big thanks to @heshan0131 and whoever else contributed to making this work in JupyterLab 2, and thank you @firasm for your guide towards making it work for me.

@khof312
Copy link

khof312 commented Jun 22, 2020

--Note-- I realized that I can't reopen this issue, so I have moved my comment into a new one below:

@poudrouxj
Copy link

Received the same error, and after countless tries to update jupyterlab + keplergl I found myself in the following situation:

JupyterLab v2.2.0
Known labextensions:
app dir: /opt/conda/share/jupyter/lab
@jupyter-widgets/jupyterlab-manager v2.0.0 enabled OK
@jupyterlab/git v0.21.1 enabled OK
@jupyterlab/google-drive v2.0.0 enabled OK
@jupyterlab/toc v4.0.0 enabled OK
jupyterlab-plotly v4.10.0 enabled OK
keplergl-jupyter v0.2.1 enabled OK
nbdime-jupyterlab v2.0.0 enabled OK
plotlywidget v4.10.0 enabled OK

Uninstalled core extensions:
keplergl-jupyter

Namely the extension was both unknown and installed, which seems to be bit of a jupyterlab bug (https://discourse.jupyter.org/t/extension-shows-up-as-both-installed-and-uninstalled-and-doesnt-work/2688/5)

Solution as suggested was to delete the build_config.json file at ../jupyter/lab/settings/build_config.json

(Sidenote: Now I finally keplergl working on my AI Notebook at google cloud platform, hurray!)

Thanks for an awesome product!

@ramayer
Copy link

ramayer commented Mar 24, 2021

If anyone's stuck on an old version of the components, this workaround worked for me:

test_map = keplergl.KeplerGl(height=600)
orig_html = str(test_map._repr_html_(),'utf-8')

better_html = orig_html
import base64
b64 = base64.b64encode(better_html.encode('utf-8'))
src = f"data:text/html;base64,{b64.decode('utf-8')}"
base64d_html = f'<iframe src="{src}" style="width:95%; height: 600px">'
import IPython
IPython.display.HTML(base64d_html)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jupyter keplergl for Jupyter
Projects
None yet
Development

No branches or pull requests

9 participants