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

Failed to load model class 'LeafletMapModel' from module 'jupyter-leaflet' #1142

Open
JosephKuchar opened this issue Oct 31, 2023 · 16 comments

Comments

@JosephKuchar
Copy link

Environment Information

ipyleaflet v.0.17.4
Python version: 3.12.0
Operating System: Ubuntu 20.04

Description

I've been trying to get a GPU-enabled docker container running with the segment anything geospatial package. I'm running a docker container of GPU Jupyter, which are GPU enabled jupyter environments. My main issue has been getting leafmap/ipyleaflet to work in this environment. After creating a fresh conda environment and installing ipyleaflet, attempting to create a map results in a javascript error in the jupyter notebook.

from ipyleaflet import Map, basemaps, basemap_to_tiles

m = Map(
    basemap=basemap_to_tiles(basemaps.OpenStreetMap.Mapnik),
    center=(48.204793, 350.121558),
    zoom=3
    )
m

And the error:

[Open Browser Console for more detailed log - Double click to close this message]
Failed to load model class 'LeafletMapModel' from module 'jupyter-leaflet'
Error: No version of module jupyter-leaflet is registered
    at f.loadClass (http://localhost:8848/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.40eaa5b8e976096d50b2.js?v=40eaa5b8e976096d50b2:1:74856)
    at f.loadModelClass (http://localhost:8848/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.b0e841b75317744a7595.js?v=b0e841b75317744a7595:1:10729)
    at f._make_model (http://localhost:8848/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.b0e841b75317744a7595.js?v=b0e841b75317744a7595:1:7517)
    at f.new_model (http://localhost:8848/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.b0e841b75317744a7595.js?v=b0e841b75317744a7595:1:5137)
    at f.handle_comm_open (http://localhost:8848/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.b0e841b75317744a7595.js?v=b0e841b75317744a7595:1:3894)
    at _handleCommOpen (http://localhost:8848/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.40eaa5b8e976096d50b2.js?v=40eaa5b8e976096d50b2:1:73393)
    at b._handleCommOpen (http://localhost:8848/static/lab/jlab_core.d992fc793fb2c108d6cc.js?v=d992fc793fb2c108d6cc:2:1037310)
    at async b._handleMessage (http://localhost:8848/static/lab/jlab_core.d992fc793fb2c108d6cc.js?v=d992fc793fb2c108d6cc:2:1039300)

I've tried upgrading and downgrading notebook, and ipyleaflet because I've seen some discussion that similar errors might result from version mismatches, but so far I've had no luck in resolving this issue. Any help appreciated!

@Sinooshka
Copy link

I have the same issue on my VM on vertex AI workbench. On my conda environment "geemap" and other related modules/packages are installed. Nevertheless I can not visualize the map.
I appreciate any relevant comment on this topic.

@carlosloslas
Copy link

I have also faced the same issue in a fresh Anaconda3 installation and following the ipyleaflet installation documentation

When I run the first example from the documentation

from ipyleaflet import Map, Marker

center = (52.204793, 360.121558)

m = Map(center=center, zoom=15)

marker = Marker(location=center, draggable=True)
m.add(marker);

display(m)

# Now that the marker is on the Map, you can drag it with your mouse,
# it will automatically update the `marker.location` attribute in Python

# You can also update the marker location from Python, that will update the
# marker location on the Map:
marker.location = (50, 356)

I run into the following error

[Open Browser Console for more detailed log - Double click to close this message]
Failed to load model class 'LeafletMapModel' from module 'jupyter-leaflet'
@http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.40eaa5b8e976096d50b2.js:1:74865
loadClass@http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.40eaa5b8e976096d50b2.js:1:75222
@http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.b0e841b75317744a7595.js:1:10738
loadModelClass@http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.b0e841b75317744a7595.js:1:10890
@http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.b0e841b75317744a7595.js:1:7531
_make_model@http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.b0e841b75317744a7595.js:1:8204
@http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.b0e841b75317744a7595.js:1:5148
new_model@http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.b0e841b75317744a7595.js:1:5194
handle_comm_open@http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.b0e841b75317744a7595.js:1:3903
@http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.40eaa5b8e976096d50b2.js:1:73409
@http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.40eaa5b8e976096d50b2.js:1:73415
@http://localhost:8888/static/lab/jlab_core.0ce4be9dd0d52754fd8a.js:2:1039655

@DonteRW
Copy link

DonteRW commented Apr 6, 2024

Any solutions?

I getting a similar or related error:

[Open Browser Console for more detailed log - Double click to close this message]
Failed to load model class 'LeafletMapModel' from module 'jupyter-leaflet'
Error: No version of module jupyter-leaflet is registered
at f.loadClass (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.fe2572ece3b7955c89bb.js?v=fe2572ece3b7955c89bb:1:74933)
at f.loadModelClass (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/336.0a90bd910629a565bb7e.js?v=0a90bd910629a565bb7e:1:10728)
at f._make_model (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/336.0a90bd910629a565bb7e.js?v=0a90bd910629a565bb7e:1:7516)
at f.new_model (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/336.0a90bd910629a565bb7e.js?v=0a90bd910629a565bb7e:1:5136)
at f.handle_comm_open (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/336.0a90bd910629a565bb7e.js?v=0a90bd910629a565bb7e:1:3893)
at _handleCommOpen (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.fe2572ece3b7955c89bb.js?v=fe2572ece3b7955c89bb:1:73470)
at v._handleCommOpen (http://localhost:8888/static/notebook/3676.bundle.js:1:30808)
at async v._handleMessage (http://localhost:8888/static/notebook/3676.bundle.js:1:32702)

The Chrome Browser console is giving me:

Error: No version of module 336.0a90bd910629a565bb7e.js?v=0a90bd910629a565bb7e:1
....

Python 3.12.2
ipyleaflet 0.18.2
geemap 0.32.0

@giswqs
Copy link
Contributor

giswqs commented Apr 6, 2024

Did you try creating a new conda env to install the packages?

@DonteRW
Copy link

DonteRW commented Apr 6, 2024

@giswqs Thanks for the response

It's a new env and a new conda python installation

@giswqs
Copy link
Contributor

giswqs commented Apr 6, 2024

How did you create the conda env and install the packages?

@DonteRW
Copy link

DonteRW commented Apr 6, 2024

@giswqs

This is basically what I have done

conda create -n pyGIS
conda activate pyGIS

started installations

conda install conda-forge::geopandas
conda install conda-forge::xarray
conda install conda-forge::conda-libmamba-solver
conda install conda-forge::cartopy
....

in order to add the env to jupyter

conda install conda-forge::ipykernel

add environ

python -m ipykernel install --user --name=pyGIS

then

conda install conda-forge::geemap

conda install conda-forge::geehydro

#=======================================================
#=======================================================

then opened a notebook & switched to the env

import geemap
import ee
import folium
import geehydro
import numpy as np
import ipyleaflet
import os

ee auth

ee.Authenticate()

init

ee.Initialize()

...

aw_dem = ee.ImageCollection("JAXA/ALOS/AW3D30/V3_2")

test plot

Map = geemap.Map()
Map.setCenter(25, -10.0, 3.0);
Map.addLayer( aw_dem, {}, 'dem')
Map

and the error shows up

@giswqs
Copy link
Contributor

giswqs commented Apr 6, 2024

Try the following. Make sure ipyleaflet works properly before installing other packages.

conda create -n gee python=3.11
conda activate gee
conda install -n base mamba -c conda-forge
mamba install geemap -c conda-forge

@DonteRW
Copy link

DonteRW commented Apr 6, 2024

@giswqs

I have installed but I am still getting the same error

But I saw a number of warnings pertaining to libmamba ( warning libmamba) during the installations, I do not know if they have any effect

e.g.
warning libmamba Could not parse mod/etag header

warning libmamba Extracted package cache 'C:\Users\yyy\anaconda3\pkgs\msys2-conda-epoch-20160418-1' has invalid size
warning libmamba Extracted package cache 'C:\Users\yyy\anaconda3\pkgs\m2w64-gcc-libs-core-5.3.0-7' has invalid size
... ...

After installaton, I have also run :

C:\Users\yyy>jupyter labextension list

And I am getting:

    bqplot v0.5.44 enabled  X (python, bqplot)
    ipyevents v2.0.1 enabled ok
    ipytree v0.2.2 enabled ok
    jupyter-leaflet v0.18.2 enabled ok
    jupyterlab-plotly v5.19.0 enabled  X
    jupyterlab_pygments v0.3.0 enabled ok (python, jupyterlab_pygments)
    @jupyter-widgets/jupyterlab-manager v5.0.10 enabled ok (python, jupyterlab_widgets)

The following extensions are outdated:
bqplot
jupyterlab-plotly

Consider checking if an update is available for these packages.

I do not know if the "outdated" packages have an effect

@kennethdamica
Copy link

I'm getting the exact same error as above. Would love a solution if anyone has found one.

@disarticulate
Copy link

heres my error:

Error: No version of module jupyter-leaflet is registered
    at f.loadClass (446.fdf8b1b233cb8c1783f6.js?v=fdf8b1b233cb8c1783f6:1:74920)
    at f.loadModelClass (327.68dbf8491690b3aff1e7.js?v=68dbf8491690b3aff1e7:1:10729)
    at f._make_model (327.68dbf8491690b3aff1e7.js?v=68dbf8491690b3aff1e7:1:7517)
    at f.new_model (327.68dbf8491690b3aff1e7.js?v=68dbf8491690b3aff1e7:1:5137)
    at f.handle_comm_open (327.68dbf8491690b3aff1e7.js?v=68dbf8491690b3aff1e7:1:3894)
    at _handleCommOpen (446.fdf8b1b233cb8c1783f6.js?v=fdf8b1b233cb8c1783f6:1:73457)
    at b._handleCommOpen (jlab_core.e5c4c4689689f1651d98.js?v=e5c4c4689689f1651d98:1:1370832)
    at async b._handleMessage (jlab_core.e5c4c4689689f1651d98.js?v=e5c4c4689689f1651d98:1:1372822)

jupyter --version:

Selected Jupyter core packages...
IPython          : 8.26.0
ipykernel        : 6.29.5
ipywidgets       : 8.1.3
jupyter_client   : 8.6.2
jupyter_core     : 5.7.2
jupyter_server   : 2.14.2
jupyterlab       : 4.2.4
nbclient         : 0.10.0
nbconvert        : 7.16.4
nbformat         : 5.10.4
notebook         : 7.2.1
qtconsole        : not installed
traitlets        : 5.14.3

@disarticulate
Copy link

reproduce:

docker run -p 10000:8888 quay.io/jupyter/scipy-notebook:2024-05-27
# install ipyleaflet
!pip install ipyleaflet
#sample code
from ipyleaflet import Map, basemaps, basemap_to_tiles

m = Map(
    basemap=basemap_to_tiles(basemaps.NASAGIBS.ModisTerraTrueColorCR, "2017-04-08"),
    center=(52.204793, 360.121558),
    zoom=4
)

m
!jupyter --version
Selected Jupyter core packages...
IPython          : 8.24.0
ipykernel        : 6.29.3
ipywidgets       : 8.1.2
jupyter_client   : 8.6.2
jupyter_core     : 5.7.2
jupyter_server   : 2.14.0
jupyterlab       : 4.2.1
nbclient         : 0.10.0
nbconvert        : 7.16.4
nbformat         : 5.10.4
notebook         : 7.2.0
qtconsole        : not installed
traitlets        : 5.14.3

@disarticulate
Copy link

got a different error with:

#docker run -p 8888:8888 jupyter/datascience-notebook:r-3.6.2

jupyter core     : 4.6.3
jupyter-notebook : 6.0.3
qtconsole        : not installed
ipython          : 7.13.0
ipykernel        : 5.1.4
jupyter client   : 6.0.0
jupyter lab      : 2.0.1
nbconvert        : not installed
ipywidgets       : 8.1.3
nbformat         : 5.0.4
traitlets        : 4.3.3
vendors~main.0219e4f42e999859f96f.js:2 Uncaught (in promise) Error: Module jupyter-leaflet, semver range ^0.18 is not registered as a widget module
    at k.loadClass (vendors~main.0219e4f42e999859f96f.js:2:1542194)
    at k.<anonymous> (vendors~main.0219e4f42e999859f96f.js:2:2058119)
    at l (vendors~main.0219e4f42e999859f96f.js:2:2054747)
    at Object.next (vendors~main.0219e4f42e999859f96f.js:2:2054038)
    at vendors~main.0219e4f42e999859f96f.js:2:2053724
    at new Promise (<anonymous>)
    at Rtm6.L (vendors~main.0219e4f42e999859f96f.js:2:2053517)
    at e._make_model (vendors~main.0219e4f42e999859f96f.js:2:2057998)
    at k.<anonymous> (vendors~main.0219e4f42e999859f96f.js:2:2057845)
    at l (vendors~main.0219e4f42e999859f96f.js:2:2054747)

@disarticulate
Copy link

when I try to manually install it:

jupyter labextension install jupyter_leaflet

from the pip store, I get the following error:

(Deprecated) Installing extensions with the jupyter labextension install command is now deprecated and will be removed in a future major version of JupyterLab.

Users should manage prebuilt extensions with package managers like pip and conda, and extension authors are encouraged to distribute their extensions as prebuilt packages
/opt/conda/lib/python3.11/site-packages/jupyterlab/debuglog.py:54: UserWarning: An error occurred.
  warnings.warn("An error occurred.")
/opt/conda/lib/python3.11/site-packages/jupyterlab/debuglog.py:55: UserWarning: ValueError: Please install nodejs >=20.0.0 before continuing. nodejs may be installed using conda or directly from the nodejs website.
  warnings.warn(msg[-1].strip())
/opt/conda/lib/python3.11/site-packages/jupyterlab/debuglog.py:56: UserWarning: See the log file for details: /tmp/jupyterlab-debug-bl09vdgo.log
  warnings.warn(f"See the log file for details: {log_path!s}")
> node -v
v12.4.0

@kennethdamica
Copy link

This isn't a true solution, but Folium worked fine when I tried it and that's good enough for my use case.

@disarticulate
Copy link

I fixed the issue in my quay.io/jupyter/scipy-notebook:notebook-7.2.1 based docker, but have no idea how. all I seem to have done is add this line before installation for cuda from nvidia:

conda install -y anaconda::nodejs ipyleaflet

It's possible there's some unfortunate resolver issues with conda or pip or between the two different packages.

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

No branches or pull requests

7 participants