没有名为对象的模块 [背景虚化]
No module named objects [bokeh]
维护者注意:这个问题不再相关。 bokeh.objects
模块已存在多年
我正在尝试 运行 这个脚本:
#Code will be significantly simplified in the 0.4 release
import time
from bokeh.objects import GlyphRenderer
renderer = [r for r in curplot().renderers if isinstance(r, GlyphRenderer)][0]
ds = renderer.data_source
while True:
df = pd.io.json.read_json(url+json_call)
ds.data["x"] = x+N*i
ds.data["y"] = df.rssi
ds._dirty = True
session().store_obj(ds)
time.sleep(1.5)
i+=1
来自:
https://www.continuum.io/content/painless-streaming-plots-bokeh
但在这一行:
from bokeh.objects import GlyphRenderer
我得到了:
No module named objects
我使用的版本是
0.11.1
在 linux 薄荷 17.1
维护者注意:此答案不再相关。 bokeh.objects
模块已存在多年
在尝试示例之前,您是否尝试安装 bokeh
?如果没有,就 运行:
pip install bokeh
然后再次尝试您的脚本。
如果它不起作用,可能是 bokeh
来源发生了变化,因此您可能需要更改
from bokeh.objects import GlyphRenderer
进入
from bokeh.models.renderers import GlyphRenderer
在你的例子的第一行它指出:
#Code will be significantly simplified in the 0.4 release
这意味着在编写本教程时该示例的代码已被弃用。
因此,您应该尝试了解它的工作原理,并使用文档和来源重新创建它,而不是 copy/pasting 该代码:
- http://docs.bokeh.org/en/latest/docs/user_guide/quickstart.html#userguide-quickstart
- https://github.com/bokeh/bokeh
玩得开心!
objects
模块已在 commit 5b5d28304c5ea209e243af5943917fe494d9ef9c
(v0.7.1) after being deprecated in 8bb4a2f1f43b39b869c508ef7aee69f7aabb46b8
(v0.7.0) 中删除。弃用消息为:“use bokeh.models instead
”。我将在当前代码库中查找 GlyphRenderer
作为练习留给您。
conda update bokeh
帮我解决了这个问题。
关于流式传输(因为这是 OP 感兴趣的示例),当前和稳定的流式传输 API 在此处演示:
https://github.com/bokeh/bokeh/tree/master/examples/app/ohlc
自 0.11.1
以来,这个简单的界面一直是有效流式传输到数据源的方式,并将继续向前发展。
基本思路是用一个数据源的所有列构造一个dict
,只需要追加新数据:
# construct a source with x and y columns
source = ColumnDataSource(data=dict(x=[....], y=[....]))
# sends the few new data points to the client, does not re-send all the data
source.stream(dict(x=[10, 11], y=[20, 21]))
通常您可能会从某种定期回调中调用流。上面链接的 OHLC 应用程序是一个完整的示例。
维护者注意:这个问题不再相关。 bokeh.objects
模块已存在多年
我正在尝试 运行 这个脚本:
#Code will be significantly simplified in the 0.4 release
import time
from bokeh.objects import GlyphRenderer
renderer = [r for r in curplot().renderers if isinstance(r, GlyphRenderer)][0]
ds = renderer.data_source
while True:
df = pd.io.json.read_json(url+json_call)
ds.data["x"] = x+N*i
ds.data["y"] = df.rssi
ds._dirty = True
session().store_obj(ds)
time.sleep(1.5)
i+=1
来自: https://www.continuum.io/content/painless-streaming-plots-bokeh
但在这一行:
from bokeh.objects import GlyphRenderer
我得到了:
No module named objects
我使用的版本是
0.11.1
在 linux 薄荷 17.1
维护者注意:此答案不再相关。 bokeh.objects
模块已存在多年
在尝试示例之前,您是否尝试安装 bokeh
?如果没有,就 运行:
pip install bokeh
然后再次尝试您的脚本。
如果它不起作用,可能是 bokeh
来源发生了变化,因此您可能需要更改
from bokeh.objects import GlyphRenderer
进入
from bokeh.models.renderers import GlyphRenderer
在你的例子的第一行它指出:
#Code will be significantly simplified in the 0.4 release
这意味着在编写本教程时该示例的代码已被弃用。
因此,您应该尝试了解它的工作原理,并使用文档和来源重新创建它,而不是 copy/pasting 该代码:
- http://docs.bokeh.org/en/latest/docs/user_guide/quickstart.html#userguide-quickstart
- https://github.com/bokeh/bokeh
玩得开心!
objects
模块已在 commit 5b5d28304c5ea209e243af5943917fe494d9ef9c
(v0.7.1) after being deprecated in 8bb4a2f1f43b39b869c508ef7aee69f7aabb46b8
(v0.7.0) 中删除。弃用消息为:“use bokeh.models instead
”。我将在当前代码库中查找 GlyphRenderer
作为练习留给您。
conda update bokeh
帮我解决了这个问题。
关于流式传输(因为这是 OP 感兴趣的示例),当前和稳定的流式传输 API 在此处演示:
https://github.com/bokeh/bokeh/tree/master/examples/app/ohlc
自 0.11.1
以来,这个简单的界面一直是有效流式传输到数据源的方式,并将继续向前发展。
基本思路是用一个数据源的所有列构造一个dict
,只需要追加新数据:
# construct a source with x and y columns
source = ColumnDataSource(data=dict(x=[....], y=[....]))
# sends the few new data points to the client, does not re-send all the data
source.stream(dict(x=[10, 11], y=[20, 21]))
通常您可能会从某种定期回调中调用流。上面链接的 OHLC 应用程序是一个完整的示例。