Jupyter notebook 未捕获引用错误:未定义Plotly
我试图从jupyter内核(基于ProcessMetaKernel)创建绘图,并在jupyter笔记本中显示绘图 我的Jupyter内核代码是Jupyter notebook 未捕获引用错误:未定义Plotly,jupyter-notebook,plotly,Jupyter Notebook,Plotly,我试图从jupyter内核(基于ProcessMetaKernel)创建绘图,并在jupyter笔记本中显示绘图 我的Jupyter内核代码是 class MyKernel(ProcessMetaKernel): def do_execute_direct(self, code, silent=True): import plotly import plotly.graph_objs as go plot_div=plotly.offline.plot({"data"
class MyKernel(ProcessMetaKernel):
def do_execute_direct(self, code, silent=True):
import plotly
import plotly.graph_objs as go
plot_div=plotly.offline.plot({"data": [go.Scatter(x=[1, 2, 3, 4], y=[4, 3, 2, 1])],"layout": go.Layout(title="hello world")}, auto_open=False, output_type='div',include_plotlyjs=True)
self.Display(HTML(data=plot_div))
return code
预期结果:在笔记本中显示绘图
实际结果:未显示绘图,在浏览器控制台中注意到以下错误消息
未捕获引用错误:未定义Plotly
at <anonymous>:7:21
at m (jquery.min.js:2)
at Re (jquery.min.js:2)
at w.fn.init.append (jquery.min.js:2)
at OutputArea._safe_append (outputarea.js:457)
at OutputArea.append_display_data (outputarea.js:660)
at OutputArea.append_output (outputarea.js:346)
at OutputArea.handle_output (outputarea.js:257)
at output (codecell.js:395)
at Kernel._handle_output_message (kernel.js:1196)
at:7:21
在m处(jquery.min.js:2)
at Re(jquery.min.js:2)
在w.fn.init.append(jquery.min.js:2)
在outputrea.\u safe\u append(outputrea.js:457)
在outputrea.append\u显示数据(outputrea.js:660)
在outputrea.append_输出(outputrea.js:346)
在outputrea.handle_输出(outputrea.js:257)
在输出端(codecell.js:395)
在内核中处理输出消息(Kernel.js:1196)