Skip to main content
 首页 » 编程设计

python之output_notebook() 未定义之为什么

2025年05月04日14langtianya

第一次尝试 Bokeh 。使用来自 http://docs.bokeh.org 的以下示例代码:

from collections import OrderedDict 
 
from bokeh.charts import Scatter 
from bokeh.sampledata.iris import flowers 
 
output_notebook() 

在iPython(Anaconda, py 3.4, Win 7)中,出现如下错误:

--------------------------------------------------------------------------- 
NameError                                 Traceback (most recent call last) 
<ipython-input-2-c57c6fa8f51a> in <module>() 
----> 1 output_notebook() 
 
NameError: name 'output_notebook' is not defined 

为什么?这直接来自示例。

请您参考如下方法:

看起来好像您忘记导入 output_notebook。

典型的笔记本有以下进口:

from bokeh.io import output_notebook, show 
from bokeh.plotting import figure 
 
output_notebook()