Reputation: 93
I have the latest Bokeh and IPython installed, and I try running the following: (all of these imports are relevant later on in the code)
import pandas as pd
import datetime
import matplotlib.pyplot as plt
import itertools as itt
import bokeh.plotting as bk
bk.output_notebook()
xs = [0,1,2,3,4,5]
ys = [x**2 for x in xs]
p.line(xs, ys, line_width=2)
p.circle(xs,ys)
bk.show(p)
After running these 2 cells, I get:
Javascript error adding output! ReferenceError: Bokeh is not defined See your browser Javascript console for more details.
So, I run the console and see this:
ReferenceError: Bokeh is not defined Stack trace: @http://localhost:8888/static/components/jquery/jquery.min.js?v=20150304125302 line 4 > eval:1:1 .globalEval@http://localhost:8888/static/components/jquery/jquery.min.js?v=20150304125302:4:4231 .domManip@http://localhost:8888/static/components/jquery/jquery.min.js?v=20150304125302:5:21389 .append@http://localhost:8888/static/components/jquery/jquery.min.js?v=20150304125302:5:18980 OutputArea.prototype._safe_append@http://localhost:8888/static/notebook/js/outputarea.js?v=20150304125302:414:13 OutputArea.prototype.append_display_data@http://localhost:8888/static/notebook/js/outputarea.js?v=20150304125302:534:13 OutputArea.prototype.append_output@http://localhost:8888/static/notebook/js/outputarea.js?v=20150304125302:320:13 OutputArea.prototype.handle_output@http://localhost:8888/static/notebook/js/outputarea.js?v=20150304125302:234:9 CodeCell.prototype.get_callbacks/<.iopub.output@http://localhost:8888/static/notebook/js/codecell.js?v=20150304125302:456:21 Kernel.prototype._handle_output_message@http://localhost:8888/static/services/kernels/kernel.js?v=20150304125302:997:13 .proxy/i@http://localhost:8888/static/components/jquery/jquery.min.js?v=20150304125302:4:5486 Kernel.prototype._handle_iopub_message@http://localhost:8888/static/services/kernels/kernel.js?v=20150304125302:1024:13 Kernel.prototype._finish_ws_message@http://localhost:8888/static/services/kernels/kernel.js?v=20150304125302:866:17 .proxy/i@http://localhost:8888/static/components/jquery/jquery.min.js?v=20150304125302:4:5486 deserialize@http://localhost:8888/static/services/kernels/serialize.js?v=20150304125302:60:13 Kernel.prototype._handle_ws_message@http://localhost:8888/static/services/kernels/kernel.js?v=20150304125302:857:9 .proxy/i@http://localhost:8888/static/components/jquery/jquery.min.js?v=20150304125302:4:5486 outputarea.js:416
Before seeing this, bk.show(p) displayed a distorted plot, saying "Hello Word", but all the buttons were deformed. matplotlib works fine.
Upvotes: 3
Views: 3410
Reputation: 400
The problem here is that Javascript
function loaded in IPython.core.display
, ommit it and re-run your code.
Upvotes: 0
Reputation: 34568
This issues was addressed in https://github.com/bokeh/bokeh/issues/2024 which moved the code that loads BokehJS into output_notebook
instead of just trying to do it when bokeh
is imported. However, I would still recommend putting bk.output_notebook
in its own ipython cell with nothing else. I am going to update the documentation to reflect this recommendation soon. The issue is that Bokeh uses IPython's "publish" mechanism to load itself, and if you put other things in a cell that also have output, it can interfere with that. Thats just the way IPython notebook works, there's not really anything else to do but to suggest putting output_notebook
on its own, so it is output is guaranteed to be correct.
Upvotes: 2
Reputation: 93
So, i restarted the system a few times, and started a new notebook, and suddenly everything works. i'm guessing the issue was with one of the imports, but i'm not 100% sure. now everything works perfect.
Upvotes: 0