Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

launch jupyter notebook in specified browser on cmd line

I'm working on a computer that belongs to my company. I don't have admin privileges, in case that's relevant.

My default browser in Windows 10 is set to InternetExplorer. This is mandated by my company. (Edge or Chrome not allowed as default browser) Although I do have Edge and Firefox installed.

I know that I can change the default browser for jupyter notebook sessions by editing the Jupyter config file. But I don't want to change the default in Jupyter.

Instead, I would like to invoke "jupyter notebook" on the command line (Anaconda prompt) while specifying which browser I want it to pick up.

something like: jupyter notebook --useBrowser edge

or similar. Is this possible?

like image 955
Gerry Harp Avatar asked Oct 20 '25 16:10

Gerry Harp


2 Answers

Try this: jupyter notebook --browser="C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe %s --new-window"

It is supposed to work like this too: jupyter notebook --browser="firefox" but doesn't in practice for me, because the python webbrowser library (which is used here) is only aware of the default browser. This needs to be manually registered.

You can check this on your system, by running a python prompt and checking:

import webbrowser
list(webbrowser._browsers)

Out: ['windows-default', 'c:\\program files\\internet explorer\\iexplore.exe']
like image 194
Kai Aeberli Avatar answered Oct 24 '25 10:10

Kai Aeberli


Noticed that if I open Firefox, use the cli command from Kai Aeberli above, as...

jupyter notebook --browser="C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe %s --new-window"

and copy and paste one of the URLs from the cli output into the Firefox (non-default browser) address bar, Jupyter Notebook opens in Firefox! Thanks for this solution! :))

like image 22
george hannan Avatar answered Oct 24 '25 08:10

george hannan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!