63

On my Windows PC, i have anaconda installed and when I open a jupyter notebook, it opens up in internet explorer, but I would like to use Chrome instead. Does anyone know how to achieve this?

pd441
  • 2,644
  • 9
  • 30
  • 41

16 Answers16

86

If you haven't already, create a notebook config file by running

jupyter notebook --generate-config

Then, edit the file jupyter_notebook_config.py found in the .jupyter folder of your home directory.

You need to change the line # c.NotebookApp.browser = '' to c.NotebookApp.browser = 'C:/path/to/your/chrome.exe %s'

On windows 10, Chrome should be located C:/Program Files (x86)/Google/Chrome/Application/chrome.exe but check on your system to be sure.

Louise Davies
  • 14,781
  • 6
  • 38
  • 41
  • Thanks for the response, but I need a more basic explanation. How do L create the config file? When I open a jupyter notebook in internet explorer and run that code I get an error... – pd441 Oct 19 '17 at 13:08
  • Where do i run `jupyter notebook --generate-config`? in the command prompt and within a jupyter notebook they both return an error – pd441 Oct 19 '17 at 13:27
  • OK, i ran the code in the anaconda prompt, and created the config file, then replaced the code as stated above, but it didn't work. Jupyter still opens in explorer... – pd441 Oct 19 '17 at 13:56
  • 13
    I just tested it myself on my windows 10 machine and it works for me. You should run the `jupyter notebook --generate-config` in the same prompt that you use to launch the notebook (so I presume in this case the anaconda prompt). Did you ensure that you removed the `#` in front of the line like in my example? If you leave the hash then the line is still commented out. Also make sure that you are using forward slashes and not backward slashes, and that you included the ` %s` part. – Louise Davies Oct 23 '17 at 09:36
  • 1
    @LouiseDavies What is '%s' used for? – J.G Feb 21 '19 at 19:32
  • 3
    @Jia Guo It's the string substitution token in Python. I may have remembered incorrectly - but I think it is because the `browser` option is literally the command Jupyter uses to create the web browser, and because we want our browser to open with the Jupyter page already open we need to pass the notebook URL to the Chrome executable. Rather than manually specify this ourselves, Jupyter can auto-insert the argument into the string so that when Chrome is opened it opens on the notebook URL. – Louise Davies Feb 22 '19 at 09:40
  • Any way to do the same on macOS? I've tried the same thing, but it stopped lunching in Safari but it didn't lunch in Chrome though, so I kept it to default. – KareemJ Apr 17 '19 at 08:31
  • I created this video which I thought might be useful: https://www.youtube.com/watch?v=g4LCiu6LzEU – Behrouz Beheshti Jan 26 '20 at 16:17
  • Thanks for this answer - it's a lifesaver for those forced to work on company laptops, where we cannot change the default browser. – Björn Feb 04 '20 at 18:13
  • Easiest way to do this in windows is go to the search bar in windows type default apps then choose chrome as default app in browser. this will change your browser to chrome and then when you enter jupyter notebook in anaconda it will automatically open in chrome. I hope it helps. – user3568896 Aug 13 '20 at 14:11
  • @user3568896 if you're able and willing then changing the default browser is an easier solution, but as other commenters have stated sometimes one is unable or unwilling to change the OS default browser, hence my answer – Louise Davies Aug 14 '20 at 08:49
34

Just make chrome as a default browser and launch the jupyter . It will work

To Make Google chrome a default browser , follow steps

  1. Click on Customize and Control Google chrome (The vertical three dots on the Upper right corner of your google chrome browser)
  2. Click on Settings and scroll down to Default browser.
  3. Change the value of the default browser to Google Chrome by clicking on whatever your default browser is there and selecting Google Chrome.

Note:

In windows 10, you will be redirected to Default apps under your computer's Settings. Please scroll down to Web browser and Select Google Chrome. If promted, Click on OK else just close the settings tab and return to your command or anaconda prompt and type jupyter notebook as usual. A new jupyter notebook tab should open in Google Chrome now.
Samuel Nde
  • 2,565
  • 2
  • 23
  • 23
jitsbits
  • 428
  • 4
  • 8
  • 1
    Please, explain better your answer, and provide a method to set the browser as default. Maybe the OP doesn't know how to do it. Please read [How do I write a good answer?](https://stackoverflow.com/help/how-to-answer) – Marc Estrada Jun 07 '18 at 06:29
  • 2
    This wasn't sufficient for me, either. Chrome is my default browser and it's still opening up in stupid Microsoft Edge. – colorlessgreenidea May 29 '19 at 17:20
  • 1
    This doesn't work for Windows 10 nor Ubuntu 18 in my tests. Writing a proper config file was needed everytime. – bkd Jul 30 '19 at 13:04
  • 4
    In Windows 10 you must also change the default app for .html files to chrome. This can be done in the "Choose default apps by file type" section of the default apps settings page. – kgoodrick Mar 09 '20 at 18:51
  • Search for "Default apps" in Start menu. Scroll down to the default browser and change it to Chrome. You are then all set to go. – code-freeze Aug 18 '20 at 03:23
27

For those who still have trouble launching Chrome automatically from cmd, try replacing

# c.NotebookApp.browser =''

in the file jupyter_notebook_config.py with

import webbrowser
webbrowser.register('chrome', None, webbrowser.GenericBrowser('C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'))
c.NotebookApp.browser = 'chrome'

or the appropriate location, there shouldn't be need to install anything via pip.

Ref: https://support.anaconda.com/customer/en/portal/articles/2925919-change-default-browser-in-jupyter-notebook

Kenny
  • 371
  • 3
  • 3
  • Thank you. I'm not sure why I had to do this when the simpler method seemed to work for others, but this works for me. Thanks! – Kevlar Oct 19 '19 at 02:32
  • yup, this is also working for me. I am using windows 10 pro version 1909, conda --version 4.7.5 – Bilal Jul 14 '20 at 04:46
  • Only this worked on Windows 10 with jupyter pip installed. Setting `c.NotebookApp.browser` to a path (with or without trailing %s did not work. – Wolfgang Kuehn Dec 13 '21 at 12:03
19

Create and edit the jupyter notebook config file with the following steps:

  • Launch Anaconda Prompt
  • Type jupyter notebook --generate-config
  • Type notepad path_to_file/jupyter_notebook_config.py to open it (change path_to_file)
  • Modify #c.NotebookApp.browser = '' to c.NotebookApp.browser = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'
  • Save the file and close it

Jupyter notebook will now use Chrome.

EDIT

In Windows 10 I had to type

  • notepad .jupyter/jupyter_notebook_config.py

And substitute the line with

  • c.NotebookApp.browser = 'C:/Program Files/Google/Chrome/Application/chrome.exe %s'
Ale
  • 917
  • 9
  • 28
10

step1: Go to search menu of windows and type default app.

step 2: go to WEB BROWSER title and change it to Google Chrome.

step3: Go to search menu of windows and type jupyter notebook

This will open the jupyter notebook in Google Chrome

Mimansa
  • 101
  • 1
  • 3
  • 1
    Even though chrome was already set as my default browser repeating these steps solved the problem for me – Lazarus Dec 23 '20 at 20:25
9
  • Run the jupyter notebook --generate-config command on the anaconda prompt.
  • Then edit the jupyter_notebook_config.py file.

Find the c.NotebookApp.Browser like this:

c.NotebookApp.browser = 'c:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'

Works on mine.

SherylHohman
  • 16,580
  • 17
  • 88
  • 94
7

Take any html file on your computer and set the default browser to open html files to chrome. This will automatically open jupyter notebook with chrome. Worked for me.

Tejas Kothari
  • 75
  • 1
  • 4
7

For windows set the default browser to open html files to Chrome. Configuration > Default Apps > Default Apps by File Type. Worked for me.

6

I found an easier solution that may help beginners to coding.

go to

C:\Users\'-your user-'\AppData\Roaming\jupyter\runtime

and find a file named

nbserver-6176-open.html

then

Right-click > open with > Choose default program...

Here, what ever you choose would be saved on your Windows to open all HTML files; therefore when you run Jupyter notebook, it would open in the program you want.

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Maz
  • 61
  • 1
  • 2
5

You don't have to change anything in the jupyter config code, you just have to make Chrome as your default browser in the setting. Jupyter opens whichever is the default.

Nan Sun
  • 51
  • 1
  • 2
5

For some reason Louise's answer didn't work for me I had to:

-Open anaconda prompt and generate the config file for Jupyter: jupyter notebook --generate-config

-Open the newly created config file at: C:\Users\builder\.juptyer\jupyter_notebook_config.py

-Add the following to the file:

import webbrowser
webbrowser.register('chrome', None, webbrowser.GenericBrowser(r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'))
c.NotebookApp.browser = 'chrome'
Rich_Foley
  • 61
  • 1
  • 7
4

I just followed 2 steps and everythings working as expected

step-1 set chrome executable path environment varibale, in my case it is(you can test it in cmd by typing chrome and enter, it will open your chrome browser if path set properly):-

C:\Program Files\Google\Chrome\Application\chrome.exe

step-2 just run below command and you are good to go

jupyter notebook --browser chrome
vivek sharma
  • 251
  • 3
  • 11
2

See response on this thread that has worked for me:

https://stackoverflow.com/a/62275293/11141700

NOTE - Additional STEP 3 that has made the difference for me compared to similar approaches suggested here

In short:

Step 1 - Generate config for Jupyter Notebook:

jupyter notebook --generate-config

Step 2 - Edit the config file using "nano" or other editor

The config fileshould be under your home directory under ".jupyter" folder:

~/.jupyter/jupyter_notebook_config.py

Step 3 - Disable launching browser by redirecting file

First comment out the line, then change True to False:

c.NotebookApp.use_redirect_file = False

Step 4 - add a line to your .bashrc file to set the BROWSER path

export BROWSER='/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe'

For me it was Chrome under my Windows Program File. Otherwise any linux installation under WSL doesn't have a native browser to launch, so need to set it to the Windows executable.

Step 5 - restart .bashrc

source .bashrc
Angelo
  • 341
  • 1
  • 2
  • 11
1

In the windows when we open jupyter notebook in command prompt we can see the instructions in first 10 lines in that there is one instruction- "to open notebook, open this file in browser file://C:/Users/{username}/appdata/roaming/jupyetr/runtime/nbserver-xywz-open.html " , open this html with browser of your choice.

DevilWhite
  • 51
  • 6
0

I just set chrome as my default browser and jupyter launches in Chrome now.

However, we have also the following approach, but it did not work for me:

"CONDA version 4.7.5 and jupyter 6.0.0. - Windows 10"

1) Open Anaconda and launch your environment in terminal

enter image description here

2) Create config file and open file in notepad

enter image description here

3) Modify line of NotebookApp with chrome and save modification

enter image description here

4) Launch Jupyter

:( ... but it still launches in Mozilla.

jorge
  • 364
  • 3
  • 8
  • Setting default browser as Chrome didnt help me, but setting html app to open by default in Chrome did the trick! – Cur123 Apr 29 '20 at 17:11
0

If you tried all these "solutions" and still doesn't work, try to open the url over HTTP (not HTTPS <-- the real problem with chrome) and using an Incognito window (press Ctrl + Shift + N on Chrome)

This worked for me. Hope it helps

icalvo
  • 111
  • 1
  • 3