How to make Jupyter Lab open using Chrome instead of Firefox on Linux

Note: This specific post only covers Jupyter Lab – not Jupyter Notebook. I have no post for Jupyter Notebook so far, but you can use a similar method here, just with slightly different config names etc.

On Ubuntu, my Jupyter Lab always opens using firefox whereas I generally want to use chrome.

In order to fix this, I first needed to generate a default config file (the echo -e "\n" part is to automatically answer no when prompted if any existing config file should be overwritten:

echo -e "\n" | jupyter lab --generate-config

Now the config file in ~/.jupyter/jupyter_lab_config.py contains this line:

# c.ServerApp.browser = ''

which we can automatically un-comment and set to chrome using:

sed -i -e "s/# c.ServerApp.browser = ''/c.ServerApp.browser = 'google-chrome'/g" ~/.jupyter/jupyter_lab_config.py

The resulting line looks like this:

c.ServerApp.browser = 'google-chrome'

Full script to use google-chrome instead of firefox

This is a script which you can copy & paste directly into your command line:

echo -e "\n" | jupyter lab --generate-config
sed -i -e "s/# c.ServerApp.browser = ''/c.ServerApp.browser = 'google-chrome'/g" ~/.jupyter/jupyter_lab_config.py