AttributeError: module 'bokeh' has no attribute 'util'

Hello,

I updated Bokeh from 0.12.13 to 0.12.15 hoping it would make it work better with jupyterlab.

However, that seems to have broken something, and now my interactive widgets don’t work anymore.

This is the error I get with my test code:

data = {‘group’:[‘yes’, ‘no’, ‘yes’, ‘yes’],‘Age’:[1,2,3,4]}

from bokeh.models import ColumnDataSource as cds

my_source = cds(data)

from ipywidgets import interact

import numpy as np

from bokeh.io import push_notebook, show, output_notebook

from bokeh.plotting import figure

from bokeh.models import BoxAnnotation, Label, Span, Band

from bokeh.palettes import Spectral6

from bokeh.transform import factor_cmap

output_notebook()

p = figure()

p = figure(x_range = (0,5), plot_height = 450, plot_width = 950, y_range = (0,1.2),

tools = ‘xwheel_zoom, xpan, reset, save’ )

r = p.vbar(x = ‘Age’, top = 1, alpha = 1, width = 0.1, legend = ‘group’, source = my_source,

color = factor_cmap(‘group’, palette = Spectral6,

factors = np.unique(my_source.data[‘group’])))

pspan = Span(location=2, dimension=‘height’, line_color=‘blue’, line_width=3, line_dash=‘dashed’)

p.add_layout(pspan)

handle = show(p, notebook_handle=True)

def update_span(right_limit):

pspan.location = right_limit

push_notebook(handle = handle)

interact(update_span, right_limit=wdg.FloatSlider(value = 2, min = 0, max = 5,

step = 0.1, layout = wdg.Layout(width = ‘950px’)))

``

In the past this gave me a figure with a slider that I could move left and right. Now all I get is this error:

···

AttributeError Traceback (most recent call last)
~/anaconda2/envs/py36/lib/python3.6/site-packages/ipywidgets/widgets/interaction.py in update(self, *args)
248 value = widget.get_interact_value()
249 self.kwargs[widget._kwarg] = value
–> 250 self.result = self.f(**self.kwargs)
251 show_inline_matplotlib_plots()
252 if self.auto_display and self.result is not None:

in update_span(right_limit)
34 def update_span(right_limit):
35 pspan.location = right_limit
—> 36 push_notebook(handle = handle)
37
38 interact(update_span, right_limit=wdg.FloatSlider(value = 2, min = 0, max = 5,

~/anaconda2/envs/py36/lib/python3.6/site-packages/bokeh/util/api.py in wrapper(*args, **kw)
188 @wraps(obj)
189 def wrapper(*args, **kw):
–> 190 return obj(*args, **kw)
191
192 wrapper.bkversion = version

~/anaconda2/envs/py36/lib/python3.6/site-packages/bokeh/io/notebook.py in push_notebook(document, state, handle)
231
232 ‘’’
–> 233 from …protocol import Protocol
234
235 if state is None:

~/anaconda2/envs/py36/lib/python3.6/site-packages/bokeh/protocol/init.py in ()
10 from tornado.escape import json_decode
11
—> 12 from . import messages
13 from . import versions
14 from .exceptions import ProtocolError

~/anaconda2/envs/py36/lib/python3.6/site-packages/bokeh/protocol/messages/init.py in ()
34 return cls
35
—> 36 from .ack import *
37 from .event import *
38 from .ok import *

~/anaconda2/envs/py36/lib/python3.6/site-packages/bokeh/protocol/messages/ack.py in ()
4 log = logging.getLogger(name)
5
----> 6 from …message import Message
7 from . import register
8

~/anaconda2/envs/py36/lib/python3.6/site-packages/bokeh/protocol/message.py in ()
43 from tornado import gen
44
—> 45 import bokeh.util.serialization as bkserial
46
47 from .exceptions import MessageError, ProtocolError

AttributeError: module ‘bokeh’ has no attribute ‘util’

Out[34]:

``

Python 3.6 under CentOS

Hi,

I have to conclude you have some sort of local installation error on your end. The bokeh.util.serialization module clearly exists:

  https://github.com/bokeh/bokeh/blob/master/bokeh/util/serialization.py

And has existed for ~3 years. Perhaps blow away anything bokeh-related in your site packages and reinstall, also double check that you are running that Bokeh version out of the same environment that the notebook is in, if you are using conda or virtual environments.

Thanks,

Bryan

···

On Apr 3, 2018, at 12:27, Micdonato <[email protected]> wrote:

Hello,

I updated Bokeh from 0.12.13 to 0.12.15 hoping it would make it work better with jupyterlab.

However, that seems to have broken something, and now my interactive widgets don't work anymore.

This is the error I get with my test code:

data = {'group':['yes', 'no', 'yes', 'yes'],'Age':[1,2,3,4]}

from bokeh.models import ColumnDataSource as cds
my_source = cds(data)

from ipywidgets import interact

import numpy as np

from bokeh.io import push_notebook, show, output_notebook
from bokeh.plotting import figure
from bokeh.models import BoxAnnotation, Label, Span, Band
from bokeh.palettes import Spectral6
from bokeh.transform import factor_cmap

output_notebook()
# p = figure()

p = figure(x_range = (0,5), plot_height = 450, plot_width = 950, y_range = (0,1.2),
           tools = 'xwheel_zoom, xpan, reset, save' )

r = p.vbar(x = 'Age', top = 1, alpha = 1, width = 0.1, legend = 'group', source = my_source,
          color = factor_cmap('group', palette = Spectral6,
                                   factors = np.unique(my_source.data['group'])))

pspan = Span(location=2, dimension='height', line_color='blue', line_width=3, line_dash='dashed')
p.add_layout(pspan)

handle = show(p, notebook_handle=True)

def update_span(right_limit):
    pspan.location = right_limit
    push_notebook(handle = handle)

interact(update_span, right_limit=wdg.FloatSlider(value = 2, min = 0, max = 5,
                                                 step = 0.1, layout = wdg.Layout(width = '950px')))

In the past this gave me a figure with a slider that I could move left and right. Now all I get is this error:

---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
~/anaconda2/envs/py36/lib/python3.6/site-packages/ipywidgets/widgets/interaction.py in update(self, *args)
    248 value = widget.get_interact_value()
    249 self.kwargs[widget._kwarg] = value
--> 250 self.result = self.f(**self.kwargs)
    251 show_inline_matplotlib_plots()
    252 if self.auto_display and self.result is not None:

<ipython-input-34-2b7d421c59ec> in update_span(right_limit)
     34 def update_span(right_limit):
     35 pspan.location = right_limit
---> 36 push_notebook(handle = handle)
     37
     38 interact(update_span, right_limit=wdg.FloatSlider(value = 2, min = 0, max = 5,

~/anaconda2/envs/py36/lib/python3.6/site-packages/bokeh/util/api.py in wrapper(*args, **kw)
    188 @wraps(obj)
    189 def wrapper(*args, **kw):
--> 190 return obj(*args, **kw)
    191
    192 wrapper.__bkversion__ = version

~/anaconda2/envs/py36/lib/python3.6/site-packages/bokeh/io/notebook.py in push_notebook(document, state, handle)
    231
    232 '''
--> 233 from ..protocol import Protocol
    234
    235 if state is None:

~/anaconda2/envs/py36/lib/python3.6/site-packages/bokeh/protocol/__init__.py in <module>()
     10 from tornado.escape import json_decode
     11
---> 12 from . import messages
     13 from . import versions
     14 from .exceptions import ProtocolError

~/anaconda2/envs/py36/lib/python3.6/site-packages/bokeh/protocol/messages/__init__.py in <module>()
     34 return cls
     35
---> 36 from .ack import *
     37 from .event import *
     38 from .ok import *

~/anaconda2/envs/py36/lib/python3.6/site-packages/bokeh/protocol/messages/ack.py in <module>()
      4 log = logging.getLogger(__name__)
      5
----> 6 from ..message import Message
      7 from . import register
      8

~/anaconda2/envs/py36/lib/python3.6/site-packages/bokeh/protocol/message.py in <module>()
     43 from tornado import gen
     44
---> 45 import bokeh.util.serialization as bkserial
     46
     47 from .exceptions import MessageError, ProtocolError

AttributeError: module 'bokeh' has no attribute 'util'

Out[34]:
<function __main__.update_span>

Python 3.6 under CentOS

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/d8231c3e-2073-4079-b7b8-14d9741c1cfb%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Well, I should have tried this before posting.

I removed bokeh and re-installed it, stopped the notebook and restarted it, and now it works.

Sorry and Thanks!

···

On Wednesday, April 4, 2018 at 12:28:42 PM UTC-7, Bryan Van de ven wrote:

Hi,

I have to conclude you have some sort of local installation error on your end. The bokeh.util.serialization module clearly exists:

    [https://github.com/bokeh/bokeh/blob/master/bokeh/util/serialization.py](https://github.com/bokeh/bokeh/blob/master/bokeh/util/serialization.py)

And has existed for ~3 years. Perhaps blow away anything bokeh-related in your site packages and reinstall, also double check that you are running that Bokeh version out of the same environment that the notebook is in, if you are using conda or virtual environments.

Thanks,

Bryan

On Apr 3, 2018, at 12:27, Micdonato [email protected] wrote:

Hello,

I updated Bokeh from 0.12.13 to 0.12.15 hoping it would make it work better with jupyterlab.

However, that seems to have broken something, and now my interactive widgets don’t work anymore.

This is the error I get with my test code:

data = {‘group’:[‘yes’, ‘no’, ‘yes’, ‘yes’],‘Age’:[1,2,3,4]}

from bokeh.models import ColumnDataSource as cds

my_source = cds(data)

from ipywidgets import interact

import numpy as np

from bokeh.io import push_notebook, show, output_notebook

from bokeh.plotting import figure

from bokeh.models import BoxAnnotation, Label, Span, Band

from bokeh.palettes import Spectral6

from bokeh.transform import factor_cmap

output_notebook()

p = figure()

p = figure(x_range = (0,5), plot_height = 450, plot_width = 950, y_range = (0,1.2),
tools = ‘xwheel_zoom, xpan, reset, save’ )

r = p.vbar(x = ‘Age’, top = 1, alpha = 1, width = 0.1, legend = ‘group’, source = my_source,

      color = factor_cmap('group', palette = Spectral6,
                               factors = np.unique(my_source.data['group'])))

pspan = Span(location=2, dimension=‘height’, line_color=‘blue’, line_width=3, line_dash=‘dashed’)

p.add_layout(pspan)

handle = show(p, notebook_handle=True)

def update_span(right_limit):

pspan.location = right_limit
push_notebook(handle = handle)

interact(update_span, right_limit=wdg.FloatSlider(value = 2, min = 0, max = 5,
step = 0.1, layout = wdg.Layout(width = ‘950px’)))

In the past this gave me a figure with a slider that I could move left and right. Now all I get is this error:


AttributeError Traceback (most recent call last)

~/anaconda2/envs/py36/lib/python3.6/site-packages/ipywidgets/widgets/interaction.py in update(self, *args)

248                     value = widget.get_interact_value()
249                     self.kwargs[widget._kwarg] = value

–> 250 self.result = self.f(**self.kwargs)

251                 show_inline_matplotlib_plots()
252                 if self.auto_display and self.result is not None:

in update_span(right_limit)

 34 def update_span(right_limit):
 35     pspan.location = right_limit

—> 36 push_notebook(handle = handle)

 37
 38 interact(update_span, right_limit=wdg.FloatSlider(value = 2, min = 0, max = 5,

~/anaconda2/envs/py36/lib/python3.6/site-packages/bokeh/util/api.py in wrapper(*args, **kw)

188         @wraps(obj)
189         def wrapper(*args, **kw):

–> 190 return obj(*args, **kw)

191
192         wrapper.__bkversion__ = version

~/anaconda2/envs/py36/lib/python3.6/site-packages/bokeh/io/notebook.py in push_notebook(document, state, handle)

231
232     '''

–> 233 from …protocol import Protocol

234
235     if state is None:

~/anaconda2/envs/py36/lib/python3.6/site-packages/bokeh/protocol/init.py in ()

 10 from tornado.escape import json_decode
 11

—> 12 from . import messages

 13 from . import versions
 14 from .exceptions import ProtocolError

~/anaconda2/envs/py36/lib/python3.6/site-packages/bokeh/protocol/messages/init.py in ()

 34     return cls
 35

—> 36 from .ack import *

 37 from .event import *
 38 from .ok import *

~/anaconda2/envs/py36/lib/python3.6/site-packages/bokeh/protocol/messages/ack.py in ()

  4 log = logging.getLogger(__name__)
  5

----> 6 from …message import Message

  7 from . import register
  8

~/anaconda2/envs/py36/lib/python3.6/site-packages/bokeh/protocol/message.py in ()

 43 from tornado import gen
 44

—> 45 import bokeh.util.serialization as bkserial

 46
 47 from .exceptions import MessageError, ProtocolError

AttributeError: module ‘bokeh’ has no attribute ‘util’

Out[34]:

Python 3.6 under CentOS


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/d8231c3e-2073-4079-b7b8-14d9741c1cfb%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.