No module named objects [bokeh]

Note from maintainers: This question is no longer relevant. The bokeh.objects module has not existed for years



I'm trying to run this script:

#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

from: https://www.continuum.io/content/painless-streaming-plots-bokeh

but at this line:

from bokeh.objects import GlyphRenderer

I got:

No module named objects

The version I'm using is

0.11.1

On linux mint 17.1

Upvotes: 3

Views: 22122

Answers (4)

zmo
zmo

Reputation: 24812

Note from maintainers: This answer is no longer relevant. The bokeh.objects module has not existed for years



did you try installing bokeh before trying the examples? If not, just run:

pip install bokeh

and try your script again.


if it does not work, it's likely that the bokeh sources changed, so you might want to change the

from bokeh.objects import GlyphRenderer

into

from bokeh.models.renderers import GlyphRenderer

cf the source code


At the first line of your example it states:

#Code will be significantly simplified in the 0.4 release

which means that the example's code was already about to be deprecated at the time of the writing of the tutorial.

So instead of copy/pasting that code, you should try to understand how it works, and recreate it using the documentation and sources:

have fun!

Upvotes: 4

bigreddot
bigreddot

Reputation: 34568

Regarding streaming (since that is is the example the OP was interested in), the current and stable streaming API is demonstrated here:

https://github.com/bokeh/bokeh/tree/master/examples/app/ohlc

This simple interface has been the way to efficiently stream to data soruces since 0.11.1, and will continue to be going forward.

The basic idea is to construct a dict with all the columns of a data source, and just the new data that is to be appended:

# 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]))

Typically you'd probably call stream from some kind of periodic callback. The OHLC app linked above is a complete example.

Upvotes: 0

RandomCoder
RandomCoder

Reputation: 7024

conda update bokeh solved this for me.

Upvotes: 0

ivan_pozdeev
ivan_pozdeev

Reputation: 36008

The objects module was deleted in commit 5b5d28304c5ea209e243af5943917fe494d9ef9c (v0.7.1) after being deprecated in 8bb4a2f1f43b39b869c508ef7aee69f7aabb46b8 (v0.7.0). The deprecation message reads: "use bokeh.models instead". I leave finding GlyphRenderer in the current codebase as an exercise for you.

Upvotes: 2

Related Questions