0

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

1

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?

  • I have jupyter_client 5.2.3 py36_0 in my old environment and jupyter_client 5.2.4 py_0 in the new one. Is this the issue? – Nick Pucino Dec 20 '18 at 0:33
  • It could explain why it didn't work in the old environment, but it doesn't explain why it does in the new one. – Marc Pfister Dec 20 '18 at 0:36
  • It worked. I just run jupyter nbextension enable --py --sys-prefix ipyleaflet in conda in my old env. Now I am able to display maps directly in my old env. Thanks a lot MarcPfister – Nick Pucino Dec 20 '18 at 0:39
0

I created a whole new virtual environment with anaconda, and installed only the basic packages (with their relative dependencies) to run ipyleaflet.

  1. ipyleaflet 0.9.1
  2. nb_conda (for creating a jupyter notebook with the purposely clean environment

Now it all works smoothly. A nice workaround will be using Jupyter Lab to run visualisations and maps in a separate kernel working in the new clean environment, and all the analysis in the "old" and cluttered environment.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.