6

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

6 Answers 6

8

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?

3
  • 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? Commented Dec 20, 2018 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. Commented Dec 20, 2018 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 Commented Dec 20, 2018 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.

0

If the above solutions didn't work try these two commands in notebook:

!jupyter labextension install @jupyter-widgets/jupyterlab-manager
!jupyter labextension install jupyter-leaflet

source here

0

You can try this at your environment.

jupyter nbextension enable --py widgetsnbextension
0

This worked for me:

    jupyter nbextension install ipyleaflet --user --py
    jupyter nbextension enable ipyleaflet --user --py

Similar with the solution for widgetsnbextension posted here:

https://github.com/jupyter-widgets/ipywidgets/issues/1146

0

After installing packages, it initially didn't work for me in the Jupyter normal address Jupyter default adress

But if you first open the http://localhost:8888/lab and then run your file in this medium, it may display the map as it did for mehttp://localhost:8888/lab

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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