没有模块命名对象[bokeh]

2024-06-07 05:29:56 发布

您现在位置:Python中文网/ 问答频道 /正文

维护人员注意:此问题不再相关。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 mint 17.1上


Tags: infromioimportjsontruedfdata
3条回答

conda update bokeh帮我解决了这个问题。

维护人员注意:此答案不再相关。bokeh.objects模块已经多年不存在了



在尝试示例之前,是否尝试安装^{}?如果没有,就跑:

pip install bokeh

再试试你的剧本。


如果它不起作用,那么很可能bokeh源发生了更改,因此您可能希望更改

from bokeh.objects import GlyphRenderer

进入

from bokeh.models.renderers import GlyphRenderer

碳纤维the source code


在示例的第一行,它声明:

#Code will be significantly simplified in the 0.4 release

这意味着在编写本教程时,示例的代码已经被弃用。

因此,与其复制/粘贴该代码,不如尝试了解其工作原理,并使用文档和源重新创建它:

玩得开心!

^{}v0.7.0)中被弃用后,objects模块在commit ^{}v0.7.1)中被删除。不赞成的消息是:“use bokeh.models instead”。我把当前代码库中的查找GlyphRenderer留给您作为练习。

相关问题 更多 >