简体   繁体   English

为什么 html 文件中没有定义来自 ipywidgets 的小部件?

[英]How come widgets from ipywidgets is not defined in an html file?

I am using nbinteract to develop an interactive web page from a Jupyter notebook.我正在使用 nbinteract 从 Jupyter 笔记本开发交互式网页。 I finally got to the end and published the first version of it but it does not appear the python libraries loaded properly (see image below).我终于到了最后并发布了它的第一个版本,但似乎没有正确加载 python 库(见下图)。 This appears to be the problem even in the original nbinteract tutorial .即使在原始的 nbinteract 教程中,这似乎也是问题所在 Any ideas on what might be the problem here?关于这里可能存在什么问题的任何想法?

Thank you谢谢

在此处输入图片说明

It's possible to export a notebook including widgets to html using nbconvert ( https://github.com/jupyter/nbconvert ).可以使用 nbconvert ( https://github.com/jupyter/nbconvert ) 将包含小部件的笔记本导出到 html。 You need to make sure to save the notebook using the classic Jupyter Notebook (not JupyterLab) with the “Widgets -> Save Notebook Widget State” menu option.您需要确保使用经典的 Jupyter Notebook(不是 JupyterLab)和“Widgets -> Save Notebook Widget State”菜单选项保存笔记本。

Unfortunately, it's not possible to preserve the behavior of the callback functions this way because these functions are defined using Python, and there's no Python kernel available in the standalone HTML file.不幸的是,不可能以这种方式保留回调函数的行为,因为这些函数是使用 Python 定义的,并且在独立的 HTML 文件中没有可用的 Python 内核。

To host interactive figures outside of the notebook , writing a Dash app is always good ( https://dash.plot.ly/ ).要在笔记本之外托管交互式图形,编写 Dash 应用程序总是很好的 ( https://dash.plot.ly/ )。 or If you want to stay in notebook/widget field you could use https://github.com/QuantStack/voila .或者如果你想留在 notebook/widget 领域,你可以使用https://github.com/QuantStack/voila

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM