Map not displayed when using `ipyleaflet` but works for `folium`
iuryt opened this issue · comments
This is always an ipylealfet installation issue. Try creating a fresh conda env to install geemap.
conda create -n gee python=3.11
conda activate gee
conda install geemap -c conda-forge
@giswqs
Is there a way to understand this problem better?
What issue in particular related to ipyleaflet do you think it generates this problem?
I am asking this because many times we need other packages in a project and it doesn't seem ideal to to create a separate environment just for gee.
Also:
I just did what you suggested, then I added the new environment to jupyter and it is reproducing exactly the same problem.
Any suggestions?
This is quite a common issue that comes up from time to time. Try the following. If it does not work, then it is an ipyleaflet installation issue. Creating a fresh con env usually should resolves the issue. If it does not, then it is probably because your jupyter environment has some restrictions that prevents the leaflet JS compoents from being loaded properly. If this is the case, you can report it to the ipyleaflet repo.
import ipyleaflet
m = ipyleaflet.Map()
m
Relevant issues:
This is quite a common issue that comes up from time to time. Try the following. If it does not work, then it is an ipyleaflet installation issue. Creating a fresh con env usually should resolves the issue. If it does not, then it is probably because your jupyter environment has some restrictions that prevents the leaflet JS compoents from being loaded properly. If this is the case, you can report it to the ipyleaflet repo.
import ipyleaflet m = ipyleaflet.Map() mRelevant issues:
Thanks for the quick response.
I just tried what you suggested and indeed, this is a problem with ipyleaflet.
Why it doesn't happen with folium? 🤔
I tried what is suggested in the documentation.
I installed ipyleaflet
and nodejs
to the base environment that I use to run jupyterlab.
then
jupyter lab build
jupyter labextension install jupyter-leaflet
When I do
jupyter labextension list
it returns
JupyterLab v4.1.6
/home/iury/miniforge3/share/jupyter/labextensions
jupyter-leaflet v0.19.1 enabled OK
jupyterlab_pygments v0.3.0 enabled OK (python, jupyterlab_pygments)
jupyterlab-quarto v0.2.8 enabled OK (python, jupyterlab-quarto)
@jupyter-widgets/jupyterlab-manager v5.0.11 enabled OK (python, jupyterlab_widgets)
@pyviz/jupyterlab_pyviz v3.0.0 enabled OK
Other labextensions (built into JupyterLab)
app dir: /home/iury/miniforge3/share/jupyter/lab
Even with all of this, I receive the following error when trying to load the map.
[Open Browser Console for more detailed log - Double click to close this message]
Failed to load model class 'LeafletMapModel' from module 'jupyter-leaflet'
Error: Module jupyter-leaflet, version ^0.18 is not registered, however, 0.19.1 is
at f.loadClass (http://localhost:10000/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/446.fdf8b1b233cb8c1783f6.js?v=fdf8b1b233cb8c1783f6:1:75041)
at f.loadModelClass (http://localhost:10000/static/lab/4416.74698273b3de2ad84746.js?v=74698273b3de2ad84746:1:11349)
at f._make_model (http://localhost:10000/static/lab/4416.74698273b3de2ad84746.js?v=74698273b3de2ad84746:1:9237)
at f.new_model (http://localhost:10000/static/lab/4416.74698273b3de2ad84746.js?v=74698273b3de2ad84746:1:6734)
at f.handle_comm_open (http://localhost:10000/static/lab/4416.74698273b3de2ad84746.js?v=74698273b3de2ad84746:1:5425)
at _handleCommOpen (http://localhost:10000/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/446.fdf8b1b233cb8c1783f6.js?v=fdf8b1b233cb8c1783f6:1:73457)
at C._handleCommOpen (http://localhost:10000/static/lab/jlab_core.1c88bfbd428297518bc8.js?v=1c88bfbd428297518bc8:1:1335202)
at async C._handleMessage (http://localhost:10000/static/lab/jlab_core.1c88bfbd428297518bc8.js?v=1c88bfbd428297518bc8:1:1337192)
Which is funny, as it complains that ^0.18 is not registered, but admits that v0.19.1 is.
But 0.19.1 is ^0.18
I checked and, in fact, there are no 0.18 versions for jupyter_leaflet
in conda-forge
mamba repoquery search jupyter_leaflet
returns
Executing the query jupyter_leaflet
conda-forge/linux-64 Using cache
conda-forge/noarch Using cache
Name Version Build Channel Subdir
──────────────────────────────────────────────────────────────────────
jupyter_leaflet 0.19.1 pyhd8ed1ab_0 (+ 1 builds) conda-forge noarch
jupyter_leaflet 0.19.0 pyhd8ed1ab_0 (+ 1 builds) conda-forge noarch
I tried to downgrade to v0.19.0
but the error persists for the other environment I had installed (gee
).
However, now it works fine for the base
environment (regardless the downgrade).
I tried to redo everything I did for the base
environment for the new gee
environment, but it still doesn't work for gee.
I think I found something.
I tried to install geemap
on the base environment and it downgraded ipyleaflet
- ipyleaflet 0.19.1 pyhd8ed1ab_0 conda-forge Cached
+ ipyleaflet 0.18.2 pyhd8ed1ab_0 conda-forge Cached
Now the problem also occurs for the base environment.
If I now upgrade ipyleaflet
mamba install ipyleaflet==0.19.1
returns
Looking for: ['ipyleaflet==0.19.1']
conda-forge/linux-64 Using cache
conda-forge/noarch Using cache
Pinned packages:
- python 3.10.*
Transaction
Prefix: /home/iury/miniforge3
Updating specs:
- ipyleaflet==0.19.1
- ca-certificates
- certifi
- openssl
Package Version Build Channel Size
───────────────────────────────────────────────────────────────
Upgrade:
───────────────────────────────────────────────────────────────
- ipyleaflet 0.18.2 pyhd8ed1ab_0 conda-forge Cached
+ ipyleaflet 0.19.1 pyhd8ed1ab_0 conda-forge Cached
Downgrade:
───────────────────────────────────────────────────────────────
- geemap 0.32.1 pyhd8ed1ab_0 conda-forge Cached
+ geemap 0.32.0 pyhd8ed1ab_1 conda-forge 2MB
Summary:
Upgrade: 1 packages
Downgrade: 1 packages
Total download: 2MB
Which downgrades geemap to 0.32.0. and now it came back working for the base environment.
It turns out that I just needed to install ipyleaflet==0.19.1
and downgrade geemap
to 0.32.0.
ipyleaflet
is working for all environments that I do this.
Is this something we should investigate why?
Why newer version of geemap
needs an older version of ipyleaflet
?