Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set jupyter notebook to open on browser automatically

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. :(

like image 376
Varun Govind Avatar asked Apr 19 '19 03:04

Varun Govind


People also ask

How do I make Jupyter notebook open automatically in Chrome?

For example to open the jupyter notebook in Google Chrome: Open Chrome, go to Settings, select the Default Browser tab, and make Chrome as your default browser. After this, the jupyter notebook will always open in Chrome.

How do I open a Jupyter notebook in browser?

Double-click on the Jupyter Notebook desktop launcher (icon shows [IPy]) to start the Jupyter Notebook App. The notebook interface will appear in a new browser window or tab. A secondary terminal window (used only for error logging and for shut down) will be also opened.

How do I keep the Jupyter notebook running?

This can be done by typing jupyter notebook in the terminal, which will open a browser. Then, navigate to the respective jupyter notebook file in the browser and open it. Click Cell > Run All on the toolbar. All done!


1 Answers

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
like image 168
gibbone Avatar answered Oct 03 '22 02:10

gibbone