Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bokeh组件api因Bokeh 10.0和Anaconda(python 2.7)发行版的错误而失败_Python_Python 2.7_Anaconda_Bokeh - Fatal编程技术网

Bokeh组件api因Bokeh 10.0和Anaconda(python 2.7)发行版的错误而失败

Bokeh组件api因Bokeh 10.0和Anaconda(python 2.7)发行版的错误而失败,python,python-2.7,anaconda,bokeh,Python,Python 2.7,Anaconda,Bokeh,当我运行这个测试程序时,我得到的错误是 x = [1, 2, 3, 4, 5] y = [6, 7, 2, 4, 5] # output to static HTML file #output_file("lines.html", title="line plot example") # create a new plot with a title and axis labels p = figure(title="simple line example", x_axis_label='x'

当我运行这个测试程序时,我得到的错误是

x = [1, 2, 3, 4, 5]
y = [6, 7, 2, 4, 5]

# output to static HTML file
#output_file("lines.html", title="line plot example")

# create a new plot with a title and axis labels
p = figure(title="simple line example", x_axis_label='x', y_axis_label='y')

# add a line renderer with legend and line thickness
p.line(x, y, legend="Temp.", line_width=2)

p1 = figure(title="simple line example", x_axis_label='x', y_axis_label='y')

# add a line renderer with legend and line thickness
p1.line(x, y, legend="Temp.", line_width=2)

return components((p, p1))
当我将字典传递给组件作为
返回组件({“p”:p,“p1”:p1})


通过anaconda在windows 64上安装Bokeh 10.0版

你执行得不正确,你的代码对我来说很有用。我认为问题在于您对返回组件((p,p1))的误解。

使用您的代码进行快速测试,并从bokeh.plotting import show获得以下信息:


我不能用Bokeh 0.10来重现这一点,而不是
return
do
show(p1)

。我注意到上面的代码片段没有定义
p2
您的
p2
是否可能是意外的Bokeh plot对象?如果我做了一个
p2
,这是一个明确的数字:

return components((p, p1))
File "C:\Working\anaconda_python_27\lib\site-packages\bokeh\embed.py" in components
ref = plot_object.ref

Exception Type: AttributeError at /backtest/mavg/
Exception Value: 'tuple' object has no attribute 'ref'

然后,
组件
按预期工作。如果您仍然遇到问题,我建议在GH问题跟踪器上提出问题

什么是回报?
components
用于在自定义模板中嵌入bokeh图,这是一件常见的事情。@bigreddot我不确定
components
,但我是从python的角度来考虑的。这就是为什么我说
返回组件((p,p1))
令人困惑,并在最后集中于
返回。
from bokeh.plotting import *
from bokeh.embed import components 
p1 = figure(title="simple line example", x_axis_label='x', y_axis_label='y')
p1.line(x, y, legend="Temp.", line_width=2)
p2 = figure(title="simple line example", x_axis_label='x', y_axis_label='y')    
p2.line(x, y, legend="Temp.", line_width=2)
components((p1, p2))