geemap: Map does not display in jupyterlab, "Loading widget..." or "Error displaying widget: model not found"
I am betting this is rather an ipyleaflet plus jupyter-lab issue, but I open this ticket hoping to provide workarounds/fixes for other users as this may be one of the first experience (i.e. impression) for newcomers.
- geemap version: 0.6.10 from conda-forge
- Python version: 3.8.2
- Operating System: Linux 4.19.0-8-amd64 #1 SMP Debian 4.19.98-1+deb10u1 (2020-04-27) x86_64 GNU/Linux
Description
example notebook 01_geemap_intro
Map
does not display in the cell output in jupyterlab, instead “Loading widget…” or “Error displaying widget: model not found”
Display works if accessed/run from jupyter-notebook however. I think I previously similar symptoms with upyleaflet
What I Did
Updated an existing conda env which had ipyleaflet working. conda update -c conda-forge python=3.8
, then conda install -c conda-forge geemap
jupyter-lab opened and requested a rebuild of the extensions:
[W 12:30:43.793 LabApp] Build recommended
[W 12:30:43.793 LabApp] jupyter-leaflet needs to be included in build
[W 12:30:43.793 LabApp] @jupyter-widgets/jupyterlab-manager needs to be included in build
Once done, Map
resulted in “Loading widget…” , but I think this was because I should have restarted jupyter-lab. Using the script
#!/bin/bash
source ${HOME}/anaconda3/bin/activate sv
jupyter-nbextension list
cd ${HOME}/src/github/geemap
jupyter-lab --browser=/usr/bin/google-chrome
Known nbextensions:
config dir: /home/xxxyyy/anaconda3/envs/sv/etc/jupyter/nbconfig
notebook section
bqplot/extension enabled
- Validating: OK
jupyter-leaflet/extension enabled
- Validating: OK
jupyter-js-widgets/extension enabled
- Validating: OK
config dir: /etc/jupyter/nbconfig
notebook section
jupyter-js-widgets/extension enabled
- Validating: OK
but upon re-execution of the notebook 01_geemap_intro Map
then leads to “Error displaying widget: model not found”
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 24 (12 by maintainers)
@jmp75 Thanks for the troubleshooting. For users who are having difficulty displaying the map, you can enable the ipyleaflet extension using the following two commands. Then you can type
jupyter nbextension list
to see whether the extension has been enabled successfully.I was almost able to follow the solution from @nanodan nanodan to get geemap to work on Jupyter Lab but I needed to modify it slightly.
I downloaded GDAL-3.2.3-cp38-cp38-win_amd64.whl and rasterio-1.2.3-cp38-cp38-win_amd64.whl from https://www.lfd.uci.edu/~gohlke/pythonlibs/ and replaced those file names in the .bat file.
I’m using conda so I also ran: conda create geelab python=3.8 conda activate geelab conda install mamba -c conda-forge
pipenv install pipenv run pip install GDAL-3.2.3-cp38-cp38-win_amd64.whl --force-reinstall pipenv run pip install rasterio-1.2.3-cp38-cp38-win_amd64.whl --force-reinstall pipenv run mamba install -c conda-forge nodejs pipenv run pip install -r requirements_fulllist.txt pipenv run jupyter labextension uninstall ipyevents pipenv run jupyter lab build pipenv run mamba install -c conda-forge pywin32
then you can start Jupyter Lab with geemap by running pipenv run jupyter lab
Once you have Jupyter Lab running try running: import geemap m = geemap.Map() m
You will get an error that says something like: FileNotFoundError: Could not find module ‘c:\users\me.virtualenvs\me-ym2aifmq\Library\bin\geos_c.dll’ (or one of its dependencies). Try using the full path with constructor syntax.
Instead of “me” in the folder names it will be your user name.
Then you have to create the “Library” and “bin” folder where they are expected (from the error), and copy the geos_c.dll from the “me-ym2aifmq\Lib\site-packages\osgeo” folder to the bin folder you just created (I tried with the shapely provided geos_c.dll and it doesn’t work).
Now if you try running that cell in Jupyter Lab again it will display a map.
This is a very convoluted solution but it does so far seem to work. Also I’m not sure how great of a practice it is to be using conda with pipenv.
Anyways, it’d be great to not have to do all this. But since @nanodan had got it working and I had to do some more stuff to get it to work on my end I thought I’d share my solution. Any idea of when there will be a better solution?
@robmarkcole This is an ipyleaflet problem rather than geemap. Check https://github.com/jupyter-widgets/ipyleaflet/issues/739 to see if it helps. You can also check out the geemap docker images at https://geemap.org/installation/#use-docker
Only way I could get this working was to fork it, modify requirements file to remove ipyevents, set ipyleaflet to 0.13.6, install ipyevents after fixed dependencies… then uninstall ipyevents from jupyterlab, while leaving it as a package, and rebuild jupyterlab, while version-fixing a whole bunch of dependencies.
.bat file
where requirements_fulllist.txt is:
Hopefully this helps somebody.
A precision for jupyterlab users, widget registrations are not the same as for jupyter-notebook. To check which extension is registered you should use
jupyter labextension list
and expect an output like:Solution:
Reading ipyleaflet issue 504 I forced a reinstall of the jupyter-leaflet extension from the command line:
jupyter-nbextension list
has the same output as before, but now the notebook does display the widget as expected. One conclusion is that you should prefer the command line for installing extensions, rather the jupyter-lab triggered 'Build"Hope this helps.