I was getting this error message even though a sample example code shown in an online course was working fine for the instructor:
OSError: Cannot pull session document because we failed to connect to the server (to start the server, try the 'bokeh serve' command)
I tried a lot and accidentally found that my code works if i include below additional import statement but interestingly i am not using it anywhere in my code.
from bokeh.server.server import Server
Here is my code:
from flask import Flask, render_template from bokeh.embed import server_document,server_session from bokeh.server.server import Server # If i comment this, I get above 'Cannot pull session document...' error. from bokeh.client import pull_session app = Flask(__name__) #create index page function @app.route("/") def index(): myurl = "http://localhost:5006/mybokeh" session = pull_session(url=myurl) bokeh_script = server_session(None, url=myurl, session_id=session.id) return render_template("index.html",bokeh_script=bokeh_script) #run the app if __name__ == "__main__": app.run(debug=True)
Any ideas why this is happening so?