bokeh serve does not execute main

Hi,

I’m trying to run a bokeh server with the command bokeh serve script.py (where script is the file name) in PyCharm’s terminal. I can see in the console “Starting Bokeh server version 0.12.5,” “Starting Bokeh server on port 5006 […] Starting Bokeh server with process id: […]” but main never runs and no browser window opens.

I’m using Python 3, I’ve added its location to the Path environment variable, and I’ve installed all bokeh packages. Any advice?

Thanks!

Hi,

If you want a browser to open automatically, you need to add the --show command line option. Otherwise, you need to open a browser and navigate to the app URL by hand.

Additionally, running "bokeh serve" on a script is not exactly like running "python" on the script. We try to make things as similar as possible, but ultimately "bokeh serve" is more like "ipython notebook" --- it's a specialized facility for executing python code in a different way (that affords other kinds of features). It might be possible to instrument the synthetic module that the Bokeh server ScriptHandler creates to set __name__ to "__main__", but I can't guarantee that for sure, there may be technical reasons why that cannot be done. It would require investigation. A GitHub issue to discuss would be welcome and appropriate.

In the mean time, there are two suggestions. Either model your script after all the existing examples (i.e. no main check just a simple script) or look at embedding the server programmatically into a "normal" python script (run with python, not with "bokeh serve"):

  https://github.com/bokeh/bokeh/tree/master/examples/howto/server_embed

Thanks,

Bryan

···

On Apr 19, 2017, at 12:17, [email protected] wrote:

Hi,

I'm trying to run a bokeh server with the command bokeh serve script.py (where script is the file name) in PyCharm's terminal. I can see in the console "Starting Bokeh server version 0.12.5," "Starting Bokeh server on port 5006 [...] Starting Bokeh server with process id: [...]" but main never runs and no browser window opens.
I'm using Python 3, I've added its location to the Path environment variable, and I've installed all bokeh packages. Any advice?

Thanks!

--
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/bd68fe9f-ff08-47d6-a360-b132140171ee%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.