jupyter-widgets / ipyleaflet

A Jupyter - Leaflet.js bridge
https://ipyleaflet.readthedocs.io
MIT License
1.47k stars 359 forks source link

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

Open JosephKuchar opened 8 months ago

JosephKuchar commented 8 months ago

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 commented 7 months ago

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 commented 6 months ago

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 commented 3 months ago

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 commented 3 months ago

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

DonteRW commented 3 months ago

@giswqs Thanks for the response

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

giswqs commented 3 months ago

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

DonteRW commented 3 months ago

@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 commented 3 months ago

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 commented 3 months ago

@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