Unable to view leaflet javascript on self-hosted JupyterLab instance?

Javascript-based maps work wonderfully in other Jupyter notebooks (i.e. planetarycomputer), but fail to render on my personal jupyterlab server. e.g. I try:

import leafmap

m = leafmap.Map()
m

and I get 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 (https://jupyter.thelio.carlboettiger.info/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.40eaa5b8e976096d50b2.js?v=40eaa5b8e976096d50b2:1:74856)
    at f.loadModelClass (https://jupyter.thelio.carlboettiger.info/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.b0e841b75317744a7595.js?v=b0e841b75317744a7595:1:10729)
    at f._make_model (https://jupyter.thelio.carlboettiger.info/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.b0e841b75317744a7595.js?v=b0e841b75317744a7595:1:7517)
    at f.new_model (https://jupyter.thelio.carlboettiger.info/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.b0e841b75317744a7595.js?v=b0e841b75317744a7595:1:5137)
    at f.handle_comm_open (https://jupyter.thelio.carlboettiger.info/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.b0e841b75317744a7595.js?v=b0e841b75317744a7595:1:3894)
    at _handleCommOpen (https://jupyter.thelio.carlboettiger.info/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.40eaa5b8e976096d50b2.js?v=40eaa5b8e976096d50b2:1:73393)
    at b._handleCommOpen (https://jupyter.thelio.carlboettiger.info/static/lab/jlab_core.3e11c5239452d671150c.js?v=3e11c5239452d671150c:2:1037311)
    at async b._handleMessage (https://jupyter.thelio.carlboettiger.info/static/lab/jlab_core.3e11c5239452d671150c.js?v=3e11c5239452d671150c:2:1039301)

Not sure what I’ve done wrong here, maybe my Jupyterlab isn’t configured correctly or needs some additional port? I’ve installed the module and tried restarting the kernel. I see that jupyter-leaflet shows up as “installed” in my “extensions” tab too – despite what the error message says… (Apologies if this kind of issue would be better directed to another forum, please let me know!)

1 Like

Since this seems like a package-specific usage question / bug report, I feel you’d probably get a faster and better response on the leafmap issue tracker:

perfect, thanks! yup, this issue appears specific to ipyleaflet driver in leafmap that is frequently reported, the other javascript drivers are working fine. Haven’t resolved it yet (no luck with previously reported solutions, which are a bit dated), but will follow up there.

@cboettig Did you find a solution to this issue?

Thanks for following up, it has all been working well for me for some time now. It’s possible my previous issues were related to a bad mix of python dependencies (including jupyter itself) with some installed from pip and others installed from conda. I tend to do pure pip or pure conda based setups now. but that’s just a guess, I haven’t replicated the failed condition. I enjoy several of the different drivers in leafmap, all work well in jupyter and I recommend them.

(Aside, I have seen some leafmap layer types not rendering correctly in code-server, though definitely a separate issue as the base leafmap works fine).

1 Like