jupyter-widgets / ipyleaflet

A Jupyter - Leaflet.js bridge
https://ipyleaflet.readthedocs.io
MIT License
1.48k stars 363 forks source link

Refused to execute script from 'path' because its MIME type ('text/html') is not executable #1072

Open Ardweaden opened 1 year ago

Ardweaden commented 1 year ago

I try to install ipyleaflet inside a Jupyter Notebook, but the map doesn't display. It only renders upon refreshing the page and running it again.

!pip install ipyleaflet
!jupyter nbextension enable --py --sys-prefix ipyleaflet

from ipyleaflet import Map, basemaps
Map(
    center=(0, 0),
    zoom=1,
    scroll_wheel_zoom=True,
    basemap=basemaps.OpenStreetMap.Mapnik,
)

Returns

[Open Browser Console for more detailed log - Double click to close this message]
Failed to load model class 'LeafletMapModel' from module 'jupyter-leaflet'
Error: Script error for "jupyter-leaflet"
http://requirejs.org/docs/errors.html#scripterror
    at makeError (http://localhost:8888/static/components/requirejs/require.js?v=d37b48bb2137faa0ab98157e240c084dd5b1b5e74911723aa1d1f04c928c2a03dedf922d049e4815f7e5a369faa2e6b6a1000aae958b7953b5cc60411154f593:168:17)
    at HTMLScriptElement.onScriptError (http://localhost:8888/static/components/requirejs/require.js?v=d37b48bb2137faa0ab98157e240c084dd5b1b5e74911723aa1d1f04c928c2a03dedf922d049e4815f7e5a369faa2e6b6a1000aae958b7953b5cc60411154f593:1735:36)

And in the browser:

Refused to execute script from 'http://localhost:8888/static/jupyter-leaflet.js?v=20221102111053' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

Version 6.5.2 with Python 3.9 on Windows.

martinRenou commented 1 year ago

I try to install ipyleaflet inside a Jupyter Notebook, but the map doesn't display. It only renders upon refreshing the page and running it again.

This is the expected behavior in the current state of ipywidgets's widget manager.

ipyleaflet needs you to load some JavaScript code which only happens upon refresh.

Ardweaden commented 1 year ago

Is there any workaround?