17

So I don't have issues trying to open the jupyter notebook but for some reason, I cannot get it to open in the browser automatically no matter what I'm trying to do. I follow these posts to no avail: unable to open jupyter(ipython) notebook on browser https://github.com/jupyter/notebook/issues/2130

I created the jupyter config through jupyter notebook --generate-config and modified these settings:

c.NotebookApp.browser = 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe' c.NotebookApp.open_browser = True
c.NotebookApp.webbrowser_open_new = 2

It still does not open the notebook automatically in chrome. I wonder if I am doing something stupid but I can't figure out what else to do. I am running on Windows 10 and launching jupyter through cygwin. When I type jupyter notebook (after modifying the settings file) in cygwin, it gives me this output:

$ jupyter notebook
[I 21:57:41.782 NotebookApp] Serving notebooks from local directory: /cygdrive/c/home
[I 21:57:41.782 NotebookApp] The Jupyter Notebook is running at:
[I 21:57:41.782 NotebookApp] http://localhost:8888/?token=373da6a3a3ed7c5fb991f0b3b1042bff22e3fa946aea8bc1
[I 21:57:41.782 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 21:57:41.799 NotebookApp]

To access the notebook, open this file in a browser:
    file:///cygdrive/c/home/.local/share/jupyter/runtime/nbserver-1003-open.html
Or copy and paste one of these URLs:
    http://localhost:8888/?token=373da6a3a3ed7c5fb991f0b3b1042bff22e3fa946aea8bc1

Is there anything else I can do to make it open in the browser automatically?

Update: I found this link and it doesn't work either: Launch IPython notebook with selected browser

I also found that this setting was wrong: c.NotebookApp.browser = 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe', it is supposed to be: c.NotebookApp.browser = 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'. But I still haven't made any progress. :(

Varun Govind
  • 983
  • 2
  • 12
  • 23
  • 3
    I am having a similar behavior on the WSL with windows 10. Jupyter is not openning the notebook boot but another page file:///home/user/.local/share/jupyter/runtime/nbserver-232-open.html . – BND Apr 26 '19 at 05:55
  • A temporarily hack may to launch the browser semi-automatically :): `nohup jupyter lab & sleep 5; /mnt/c/Program\ Files\ \(x86\)/SeaMonkey/seamonkey.exe `grep -om1 http.* nohup.out` ` – BND Apr 26 '19 at 06:04
  • Hey, thanks for the comment! I couldn't figure out my problem and simply re-installed everything from scratch. By everything, I mean Cygwin, python, all my libraries, dependencies, and whatever utilities I had before. I don't know what the issue was previously but doing a simple refresh on my cygwin and python installations fixed all my problems. If you have any other suggestions for this problem, they are greatly appreciated! – Varun Govind Apr 28 '19 at 00:40
  • I couldn't find any other solution. A recent related issue [here](https://github.com/jupyter/notebook/issues/4594), the problem may be related to the integration with windows. – BND Apr 28 '19 at 06:32

4 Answers4

21

Add this line to your jupyter_notebook_config.py file:

c.NotebookApp.use_redirect_file = False

This should open jupyter notebooks automatically in your browser with the localhost/127.0.0.1 URL.

More info for the sake of completeness:

  • The config file should be found in ~/.jupyter/jupyter_notebook_config.py. If missing can be generated (as you did) with the command: jupyter notebook --generate-config
  • Here's the Github issue where the change was discussed (the same solution was also highlighted here)
  • Here's the reference in the documentation
gibbone
  • 2,300
  • 20
  • 20
  • Thank you. For me, it was working on wsl1, but I recently moved from wsl1 to wsl2 and it is not working. Do you know why? – 8Simon8 Nov 21 '22 at 16:32
4

At the command line, type:

jupyter notebook --browser=<Browser>

<Browser> being Chrome, Safari, Firefox, etc.

Reblochon Masque
  • 35,405
  • 10
  • 55
  • 80
2

You can fix it by setting to 'false' this setting in the config file

If not already done, generate a config file : jupyter notebook --generate-config

Then update this : NotebookApp.use_redirect_file to False (defaulted as True) in ~/.jupyter/jupyter_notebook_config.py

(from https://jupyter-notebook.readthedocs.io/en/stable/config.html)

NotebookApp.use_redirect_fileBool

Default: True

Disable launching browser by redirect file For versions of notebook > 5.7.2, a security feature measure was added that prevented the authentication token used to launch the browser from being visible. This feature makes it difficult for other users on a multi-user system from running code in your Jupyter session as you.

However, some environments (like Windows Subsystem for Linux (WSL) and Chromebooks), launching a browser using a redirect file can lead the browser failing to load. This is because of the difference in file structures/paths between the runtime and the browser. Disabling this setting to False will disable this behavior, allowing the browser to launch by using a URL and visible token (as before).

0

I found a simple way to resolve this issue on any Windows OS.

Follow these steps:

  1. Press Win + R to open the Run dialog box.
  2. Type %AppData% in the box and hit Enter. This will take you directly to the AppData/Roaming folder for your user profile.
  3. In the Roaming folder, navigate to jupyter > runtime.
  4. Right-click on nbserver and select "Open With" to choose a browser of your choice.

See image below:

f

Andreas Violaris
  • 2,465
  • 5
  • 13
  • 26