Tuesday, 20 December 2016

leaflet - Ipyleaflet map object doesn't display in Jupyter Notebook but it gets created



When running the code from the example (https://ipyleaflet.readthedocs.io/en/latest/api_reference/map.html#example), no map get displayed.


from ipyleaflet import Map, basemaps, basemap_to_tiles

m = Map(
layers=(basemap_to_tiles(basemaps.NASAGIBS.ModisTerraTrueColorCR, "2017-04-08"), ),
center=(52.204793, 360.121558),
zoom=4
)

m


No error message pops up. The map object gets created:


type(m)
>>> ipyleaflet.leaflet.Map

It just doesn't get rendered. Any hints?


After a while, this message appears : "A Jupyter widget could not be displayed because the widget state could not be found. This could happen if the kernel storing the widget is no longer available, or if the widget state was not saved in the notebook. You may be able to create the widget by running the appropriate cells."


It suggests that something with the widget is not working, but I can't understand what.


Versions: ipyleaflet: 0.9.1 ipywidgets: 7.4.2



Answer




I just tried to install ipyleaflet with Jupyter 5.2.3:


conda install -c conda-forge ipyleaflet

and also didn't get a map. I then tried registering the extension with:


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

since this is mentioned after the install with pip section.


After restarting the kernel, the map was now displayed.


Is jupyter_client in your old environment <5.3, and >=5.3 in the new clean one?


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...