2017-08-04 54 views
0

我已经尝试了一个简单的内联教程,并使用cookiecutter模板来制作Jupyter小部件,但不加载小部件。无法加载Jupyter笔记本中的自定义小部件

当我尝试这个tutorial即使是hello世界小部件,我也只是打印出“Jupyter Widget”,并在控制台中获得“404 GET /nbextensions/widgets/notebook/js/extension.js”。

当我尝试内嵌例子,我在控制台中“404 GET /static/@jupyter-widgets/base.js”为直列例子的代码此错误只是

import ipywidgets as widgets 
from traitlets import Unicode, validate 


class HelloWidget(widgets.DOMWidget): 
    _view_name = Unicode('HelloView').tag(sync=True) 
    _view_module = Unicode('hello').tag(sync=True) 
    _view_module_version = Unicode('0.1.0').tag(sync=True) 

%%javascript 
require.undef('hello'); 

define('hello', ["@jupyter-widgets/base"], function(widgets) { 

    var HelloView = widgets.DOMWidgetView.extend({ 

    // Render the view. 
    render: function() { 
     this.el.textContent = 'Hello World!'; 
    }, 
    }); 

    return { 
     HelloView: HelloView 
    }; 
}); 

这是在conda虚拟环境中,Jupyter 4.2.1和笔记本4.3.1

在此先感谢您的帮助。

回答

0

我在使用pip安装后忘记运行jupyter nbextension enable --py widgetsnbextension时遇到了同样的问题;详情请看这里http://ipywidgets.readthedocs.io/en/latest/user_install.html。好像conda应该为你启用了扩展。我没有任何与conda的经验,但似乎你可以通过conda install -c anaconda ipywidgetsconda install -c conda-forge ipywidgets安装ipywidgets,想想也许conda-forge安装可能会更新?

0

重新安装所有jupyter和ipython相关的pip软件包为我解决了这个问题。

相关问题