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?
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"):
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?