Even Sample Bokeh plot is not rendering


Am a complete noob in bokeh. Doing this for the first time. I copied a sample plot from Python Bokeh tutorial - Interactive Data Visualization with Bokeh - GeeksforGeeks

To run the code, this is what I did:

  1. installed latest bokeh version (it was a new install). Installation was with pip
  2. ran in python 3.10 version
  3. pasted below code for plotting into a temp.py file:
from bokeh.plotting import figure, output_file, show
graph = figure( title = "Bokeh Line Graph" )
x = [1, 2, 3, 4, 5]
y = [5, 4, 3, 2, 1]
graph.line( x, x, legend_label = "Line 1" )
graph.line( y, x, legend_label = "Line 2",
           line_color = "green" )
show( graph )
  1. ran it.
  2. File is getting generated. Am opening it via MS Edge (retried with chrome as well)
  3. File is opening; Only issue is that its an empty page.
  4. I checked the file in explorer (copied file location from edge/chrome’s address bar)
  5. File does exist, and is of non-zero size

What am I doing wrong?

I rechecked the entries in community page - there’s no mention of this issue anywhere (except one from 2015), so I’m guessing I am doing something wrong … I just cant figure out what the error is. Any help will be appreciated.

I tired attaching the html file here, but the website isnt allowing it…

Hi @arun please edit your post to use code formatting so that the code is intelligible (either with the </> icon on the editing toolbar, or triple backtick ``` fences around the code blocks). I had to manually edit all “fancy quotes” to be plain ascii quotes in order to run your code.

Your code produces the expected output for me on OSX/Chrome:

Does your output work on other browers besides Edge? What version of Edge (old non-Chromium Edge, or recent Chromium-based Edge?)

I have bumped you up from New User, you should be able to attach your file now. Or if not, you can put it in a gist: https://gist.github.com/ so that we can look at it.

Thanks for the reply.

I just rechecked - I was working from a PC which blocks execution of javascript. I just opened the html file from my normal PC, and it is working just fine!

Really sorry for the hiccup - I didnt realize we have this kind of segregation.

If the issue is blocking execution of JavaScript, then Bokeh will not be an option. However, if the issue is actually with loading JavaScript remotely over a network, then note that is is possible to generate Bokeh output with “inline” resources (all required JS is contained directly within the HTML output).

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.