Setting the default browser for --show on windows


I just wanted to share a little trick for using efficiently using the --show argument with bokeh serve on windows.

My pain is that the default browser is edge and cannot be changed for reasons outside of my control. I could see that I could set the default browser for Bokeh/ Panel using the BOKEH_BROWSER environment variable. But when I tried setting it to chrome or firefox it did not work. After some reverse engineering of the webbrowser module I found out I need to set

BOKEH_BROWSER="C:/Program\ Files/Google/Chrome/Application/chrome.exe %s &"

BOKEH_BROWSER="C:/Program\ Files\ (x86)/Mozilla\ Firefox/firefox.exe %s &"

or something similar.

It’s important you replace

  • “\” with “/” and

  • space with "\ "

so now I can run

python -m bokeh serve --dev --show

and the app automatically opens in the right browser initially and when I change and save the code.

1 Like

Thanks, @MarcSkovMadsen! That is pretty handy, and I expect by sharing it here you’ve shortcut someone’s figuring this out in the future. I’ve also put in a GH issue to make this option clear in the docs.

1 Like

FWIW this (and all other) env vars are documented in the reference for bokeh.settings:

1 Like