Ipywidgets: jupyter-js-widget issue upon save notebook widget state

Created on 1 Aug 2018  ·  3Comments  ·  Source: jupyter-widgets/ipywidgets

Please see my edit below about what I think this is more about.

Hello, I'm having an issue with the 'save notebook widget state' feature and I do not believe I'm the only one. In short, I'm creating a widget in a notebook, save notebook widget state, then nbconvert to html. But when I open the html, the widget does not render unless you swap out

<script src="https://unpkg.com/[email protected].*/dist/embed.js"></script>

to this

<script src="https://unpkg.com/@jupyter-widgets/html-manager@*/dist/embed-amd.js" crossorigin="anonymous"></script>

Also the require.js version seems to be out of date (2.1.10 instead of 2.3.4) but it seems to work regardless.

~This is basically following the section in the docs that describes embedding custom widgets. But I don't think what I'm using is a custom widget, I'm just using the built in tabs feature (unless my understanding of a custom widget is wrong).~
EDIT: I realized I skipped over the regular embedding section, would it be possible to include the html-manager when saving the widget state or would that create other/unforeseen complications?


If I keep the current line in, the error looks like:

Loading failed for the <script> with source “file:///Users/kmyers/Desktop/@jupyter-widgets/base.js”. [filename].html:1
Loading failed for the <script> with source “file:///Users/kmyers/Desktop/@jupyter-widgets/output.js”. [filename].html:1
Loading failed for the <script> with source “file:///Users/kmyers/Desktop/@jupyter-widgets/controls.js”. [filename].html:1
Loading failed for the <script> with source “https://unpkg.com/@jupyter-widgets/[email protected]/dist/index.js”. [filename].html:1
[Show/hide message details.] Error: Script error for: https://unpkg.com/@jupyter-widgets/[email protected]/dist/index.js
http://requirejs.org/docs/errors.html#scripterror require.min.js:8:252
Loading failed for the <script> with source “https://unpkg.com/@jupyter-widgets/[email protected]/dist/index.js”. [filename].html:1
[Show/hide message details.] Error: Script error for: https://unpkg.com/@jupyter-widgets/[email protected]/dist/index.js
http://requirejs.org/docs/errors.html#scripterror require.min.js:8:252
Loading failed for the <script> with source “https://unpkg.com/@jupyter-widgets/[email protected]/dist/index.js”. [filename].html:1
[Show/hide message details.] Error: Script error for: https://unpkg.com/@jupyter-widgets/[email protected]/dist/index.js
http://requirejs.org/docs/errors.html#scripterror require.min.js:8:252
C
https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js:8:252
onScriptError
https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js:29:514

(sorry I'm not really great with JS and wasn't sure of the proper way to copy this from the inspector).


Alternatively (again I don't know if this is possible because I'm not skilled in JS but) would it be possible to somehow put the script line in the first cell of a notebook and have it override the original line and perhaps redraw the rest of the cells? I have tried this but still get a few errors and no rendering. Anyone have any thoughts on this?


I'm using ipywidgets==7.3.1, widgetsnbextension-3.3.1, notebook==5.6.0, and nbconvert==5.3.1.

resolved-locked

Most helpful comment

Sorry, this fell between the cracks. Added comment to the PR.

All 3 comments

If I understand the issue correctly, the issue lies with nbconvert: https://github.com/jupyter/nbconvert/pull/792 Unfortunately, this PR is simply being ignored 😕

Sorry, this fell between the cracks. Added comment to the PR.

@vidartf @SylvainCorlay cool! thanks guys, makes sense this gets set in the conversion and not the save state

Was this page helpful?
0 / 5 - 0 ratings