0 votes
1 view
in Azure by (5.8k points)

I can run the following code in a Jupyter notebook (Python 3.5) on my PC using Anaconda, and it works fine. But when I run the same code in an Azure ML notebook, I get the plot, but also the error message described below. Does anyone know how to use Bokeh in Azure ML notebooks ? Is there perhaps a way to import the seemingly missing module 'ipykernel'

from bokeh.plotting import figure, show, output_notebook

from bokeh.sampledata.iris import flowers

colormap = {'setosa': 'red', 'versicolor': 'green', 'virginica': 'blue'}

colors = [colormap[x] for x in flowers['species']]

p = figure(title = "Iris Morphology")

p.xaxis.axis_label = 'Petal Length'

p.yaxis.axis_label = 'Petal Width'

p.circle(flowers["petal_length"], flowers["petal_width"],

     color=colors, fill_alpha=0.2, size=10)



produces the plot, but also the following errors

ImportError                               Traceback (most recent call last)

<ipython-input-17-c50d1a94007e> in <module>()


 14 output_notebook()

---> 15 show(p)

/home/nbuser/env3/lib/python3.4/site-packages/bokeh/io.py in show(obj,        browser, new)


    300     '''

--> 301     return _show_with_state(obj, _state, browser, new)


    303 def _show_with_state(obj, state, browser, new):

/home/nbuser/env3/lib/python3.4/site-packages/bokeh/io.py in     _show_with_state(obj, state, browser, new)


    308     if state.notebook:

--> 309         comms_handle = _show_notebook_with_state(obj, state)


    311     elif state.server_enabled:

/home/nbuser/env3/lib/python3.4/site-packages/bokeh/io.py in     _show_notebook_with_state(obj, state)

    329         comms_target = make_id()

    330         publish_display_data({'text/html': notebook_div(obj,   comms_target)})

--> 331         handle = _CommsHandle(get_comms(comms_target), state.document,     state.document.to_json())

    332         state.last_comms_handle = handle

    333         return handle

/home/nbuser/env3/lib/python3.4/site-packages/bokeh/util/notebook.py in   get_comms(target_name)


    110     '''

--> 111     from ipykernel.comm import Comm 

    112     return Comm(target_name=target_name, data={})


ImportError: No module named 'ipykernel'

In [16]:

1 Answer

0 votes
by (9.6k points)

You can try this:

!conda install ipykernel --yes

Welcome to Intellipaat Community. Get your technical queries answered by top developers !