kepler.gl: [Bug][Jupyter Widget] Error displaying widget: model not found

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:

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (2 by maintainers)

Most upvoted comments

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)

just published keplergl==0.2.0 with support for JupyterLab 2.0

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.

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

pip install keplergl —upgrade

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.

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

You can try my instructions here: https://github.com/firasm/keplergl_tutorial/blob/master/1 - Install/Installation instructions.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

Upgrade widget to kepler.gl@^2 and supporting JupyterLab 2 https://github.com/keplergl/kepler.gl/pull/1110