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

Map does not display in jupyterlab, "Loading widget..." or "Error displaying widget: model not found" #31

Closed
jmp75 opened this issue May 6, 2020 · 24 comments
Labels
good solution Good solutions provided by geemap users

Comments

@jmp75
Copy link

jmp75 commented May 6, 2020

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.

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"

@jmp75
Copy link
Author

jmp75 commented May 6, 2020

Solution:

Reading ipyleaflet issue 504 I forced a reinstall of the jupyter-leaflet extension from the command line:

conda activate sv # or whatever you have named it
jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyter-leaflet

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.

@giswqs
Copy link
Member

giswqs commented May 6, 2020

@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.

jupyter nbextension install --py --symlink --sys-prefix ipyleaflet
jupyter nbextension enable --py --sys-prefix ipyleaflet

@giswqs giswqs added the good solution Good solutions provided by geemap users label May 8, 2020
@giswqs giswqs closed this as completed May 8, 2020
@jmp75
Copy link
Author

jmp75 commented May 10, 2020

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:

JupyterLab v2.0.0
Known labextensions:
   app dir: /home/xxxyyy/anaconda3/envs/sv/share/jupyter/lab
        @jupyter-widgets/jupyterlab-manager v2.0.0  enabled  OK
        bqplot v0.5.10  enabled  OK
        jupyter-leaflet v0.12.4  enabled  OK

@LucaD81
Copy link

LucaD81 commented Nov 30, 2020

the solution proposed is not working for me...
only way to work for me is:

import geemap.eefolium as geemap
Map = geemap.Map()
Map

However, in a later stage I try to add layers (following tutorial #12):

Add Earth Engine dataset

dem = ee.Image('USGS/SRTMGL1_003')

Set visualization parameters.

dem_vis = {
'min': 0,
'max': 4000,
'palette': ['006633', 'E5FFCC', '662A00', 'D8D8D8', 'F5F5F5']}

Add Earth Engine DEM to map

Map.addLayer(dem, dem_vis, 'SRTM DEM')

I cannot see any layers, Dont know why...

@giswqs
Copy link
Member

giswqs commented Nov 30, 2020

@LucaD81 How did you install geemap? Try the following commands:

conda create -n gee python=3.8
conda activate gee
pip install geemap

@LucaD81
Copy link

LucaD81 commented Dec 1, 2020

Hi, thanks for your quick response!
Previsouly I installed using: conda install -c conda-forge geemap
Now I run your command lines, but unfortunately it's still not working.
When using import geemap.eefolium as geemap, it's opening the interactive-map, but after adding layers, I cannot see the layers anyway...thanks!

@giswqs
Copy link
Member

giswqs commented Dec 1, 2020

@LucaD81

conda activate gee
jupyter nbextension install --py --symlink --sys-prefix ipyleaflet
jupyter nbextension enable --py --sys-prefix ipyleaflet

@giswqs
Copy link
Member

giswqs commented Dec 1, 2020

@LucaD81 You can also try Google Colab if you cannot get geemap to work on your computer. See this example.

@LucaD81
Copy link

LucaD81 commented Dec 1, 2020

I tried commands of above and that's what I've got:
RuntimeError: The current Numpy installation ('c:\users\lucad\.conda\envs\gee\lib\site-packages\numpy\init.py') fails to pass a sanity check due to a bug in the windows runtime. See this issue for more information: https://tinyurl.com/y3dm3h86

for GColab ok, but I've read there might be some issues with other packages

@giswqs
Copy link
Member

giswqs commented Dec 1, 2020

See this.

conda activate gee
pip install numpy==1.19.3

@LucaD81
Copy link

LucaD81 commented Dec 1, 2020 via email

@giswqs
Copy link
Member

giswqs commented Dec 1, 2020

@LucaD81 Try creating a fresh conda env to install ipyleaflet first. Make sure that you can show an ipyleaflet map before installing geemap. If ipyleaflet does not work properly, geemap won't work either.

https://ipyleaflet.readthedocs.io/en/latest/installation.html

import ipyleaflet
m = ipyleaflet.Map()
m

@nanodan
Copy link

nanodan commented Feb 6, 2021

I have this same issue. It's an issue with leaflet. Upgrading leaflet to 0.13.6 solves the problem, but geemap currently has a dependency of <=0.13.3

@giswqs
Copy link
Member

giswqs commented Feb 6, 2021

@nanodan Thanks for reporting. I temporarily set the ipyleaflet dependency of <=0.13.3 because ipyleaflet >0.13.4 has some installation issues on Windows. See jupyter-widgets/ipyleaflet#769. I will remove the dependency version once the issue gets resolved.

@nanodan
Copy link

nanodan commented Feb 6, 2021

@giswqs Thanks for the quick update. I can get leaflet widgets to display with 0.13.6 (I'm on windows and had no problems installing). I tried to fork geemap and fix ipyleaflet to 0.13.6 but it seems that once ipyevents gets installed, which is one of the dependencies, it breaks leaflet for some reason... Downgrading ipyevents to 0.8.0 doesn't help. If I remove ipyevents and rebuild jupyterlab then I can display widgets again... though now ipyevents is showing up as both enabled/uninstalled at the same time... and of course it is a requirement, so I'm not entirely sure what the actual problem is.

@giswqs
Copy link
Member

giswqs commented Feb 6, 2021

@nanodan I just tested the pip installation of ipyelaflet with a fresh conda env, it still does not work. The installation went fine, but it throws an error relates the the shapely dependency. Long story short, ipyleaflet >0.13.3 only works on Windows with conda install but not with pip install.

@nanodan
Copy link

nanodan commented Feb 6, 2021

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

pipenv install
pipenv run pip install GDAL-3.2.1-cp39-cp39-win_amd64.whl
pipenv run pip install rasterio-1.2.0-cp39-cp39-win_amd64.whl
pipenv run pip install -r requirements_fulllist.txt
pipenv run jupyter labextension uninstall ipyevents
pipenv run jupyter lab build

where requirements_fulllist.txt is:

git+https://github.com/nanodan/geemap
affine==2.3.0
anyio==2.0.2
argon2-cffi==20.1.0
async-generator==1.10
attrs==20.3.0
Babel==2.9.0
backcall==0.2.0
bleach==3.3.0
branca==0.4.2
certifi==2020.12.5
cffi==1.14.4
chardet==4.0.0
click==7.1.2
click-plugins==1.1.1
cligj==0.7.1
colorama==0.4.4
decorator==4.4.2
defusedxml==0.6.0
entrypoints==0.3
idna==2.10
ipykernel==5.4.3
ipyleaflet==0.13.6
ipython==7.20.0
ipython-genutils==0.2.0
ipywidgets==7.6.3
jedi==0.18.0
Jinja2==2.11.3
json5==0.9.5
jsonschema==3.2.0
jupyter-client==6.1.11
jupyter-core==4.7.1
jupyter-server==1.3.0
jupyterlab==3.0.7
jupyterlab-pygments==0.1.2
jupyterlab-server==2.2.0
jupyterlab-widgets==1.0.0
MarkupSafe==1.1.1
mistune==0.8.4
nbclassic==0.2.6
nbclient==0.5.1
nbconvert==6.0.7
nbformat==5.1.2
nest-asyncio==1.5.1
notebook==6.2.0
numpy==1.20.0
packaging==20.9
pandocfilters==1.4.3
parso==0.8.1
pickleshare==0.7.5
prometheus-client==0.9.0
prompt-toolkit==3.0.14
pycparser==2.20
Pygments==2.7.4
pyparsing==2.4.7
pyrsistent==0.17.3
python-dateutil==2.8.1
pytz==2021.1
pywin32==300
pywinpty==0.5.7
pyzmq==22.0.2
requests==2.25.1
Send2Trash==1.5.0
Shapely==1.7.1
six==1.15.0
sniffio==1.2.0
snuggs==1.4.7
terminado==0.9.2
testpath==0.4.4
tornado==6.1
traitlets==5.0.5
traittypes==0.2.1
urllib3==1.26.3
wcwidth==0.2.5
webencodings==0.5.1
widgetsnbextension==3.5.1
ipyevents

Hopefully this helps somebody.

@giswqs
Copy link
Member

giswqs commented Feb 6, 2021

@nanodan Thanks for providing the solution. Hope it will be helpful for Windows users.

@robmarkcole
Copy link

Having run

jupyter nbextension install --py --symlink --sys-prefix ipyleaflet
jupyter nbextension enable --py --sys-prefix ipyleaflet

The error is cleared but the notebook hangs on Loading widget... Any advice?
Noting I am using a jupyter docker image (jupyter/scipy-notebook:latest) but I dont think this should compound the underlying issue

@giswqs
Copy link
Member

giswqs commented Mar 3, 2021

@robmarkcole This is an ipyleaflet problem rather than geemap. Check jupyter-widgets/ipyleaflet#739 to see if it helps. You can also check out the geemap docker images at https://geemap.org/installation/#use-docker

@jwingnut
Copy link

jwingnut commented May 9, 2021

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?

@giswqs
Copy link
Member

giswqs commented May 9, 2021

@jpwhitney Thanks for sharing your solution! The other potential solution is to use Windows Subsystem for Linux. I have not tested it yet, but I think WSL could be useful for installing those packages that are very challenging to install on Windows.

@OfirMazor
Copy link

I want to share my experience with the same error: "Error displaying widget: model not found" .
After upgrading to Jupyterlab 3, for some reason, I had to reinstall all of my lab extensions. Only after I installed Ipyevents extension the problam was fixed.

using:
windows 10
Anaconda navigator

@giswqs
Copy link
Member

giswqs commented Jun 3, 2021

You can also use the geemap Binder JupyterLab environment: https://gishub.org/geemap-lab
See the environment.yml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good solution Good solutions provided by geemap users
Projects
None yet
Development

No branches or pull requests

7 participants