Shreyas Kulkarni
Shreyas' Blog

Shreyas' Blog

How to change the default browser for jupyter Notebook and jupyter Lab with CMD?

How to change the default browser for jupyter Notebook and jupyter Lab with CMD?

It takes 5 mins to change the default browser for jupyter without changing system-wide default browser.

Shreyas Kulkarni
·Oct 2, 2021·

2 min read

Subscribe to my newsletter and never miss my upcoming articles

Listen to this article

I have been searching for the exact steps to follow for changing the default browser only for jupyter products (notebook and lab).

However, I came across various steps but somehow they were not exact, not really documented in a proper way.

to solve that here I am going to document those steps which will be beneficial to follow and get it done easily.

To generate-config file run this in Anaconda prompt or CMD whichever you are using:

"jupyter notebook --generate-config "

step.png

Locate the generated configuration file in the path In my case the path was

C:\Users\Shrey.jupyter\jupyter_notebook_config.py

and open it with notepad/any text editor then find below syntax:

## Specify what command to use to invoke a web browser when opening the notebook.
#  If not specified, the default browser will be determined by the `webbrowser`
#  standard library module, which allows setting of the BROWSER environment
#  variable to override it.
#  Default: ''
# c.NotebookApp.browser = ''

path change.png

Here you care about the last line where you need to do change

I am using chrome to do so but you can do it for any browser of your wish :)

Just right click on the browser icon in the taskbar right-click again on chrome or a new tab whichever works for you Go to properties and copy the target path

chrome.png

target.png

and paste that path as stated below

Note: start with this syntax u'path %s'

c.NotebookApp.browser = u'C:\Program Files\Google\Chrome\Application\chrome.exe %s'

don't forget to remove "#" of that particular line

Save the file and close it, close anaconda prompt launch it again, this try usual way to open jupyter notebook. this time the jupyter notebook will open in your desired browser. ​

for jupyter lab, the procedure is the same just syntax is different I am listing required changes to be done down here, please follow the same for the jupyter lab

To generate-config file run this in Anaconda prompt or CMD whichever you are using:

jupyter-lab --generate-config

this time changes are needed here:

c.ServerApp.browser =

lab change.png

In my case, the path is just for your reference

 c.ServerApp.browser = u'C:/Program Files/Google/Chrome/Application/chrome.exe %s'

copy browser target path and paste it in the required way, don't forget to remove the # of that particular line and save the file.

Done, Next time lab will also open in your desired browser

Thanks for reading, catch you in the next one.

 
Share this