5

Is there a way to configure Ubuntu 18.04 to open Jupyter Notebooks with a double click from the graphical file browser?

There are 2 prominent Stack Overflow posts on the subject:

https://stackoverflow.com/questions/30953227/double-click-to-open-an-ipython-notebook

https://stackoverflow.com/questions/30953227/double-click-to-open-an-ipython-notebook/30955613

But most of the answers here pertain to MacOS, and the few relating to Linux did not seem to work for me on Ubuntu 18.04.

Something completely different from the above that I tried was to make a desktop file:

cd ~/.local/share/applications
gedit jupyter_notebook.desktop

In Gedit I entered this:

[Desktop Entry]
Comment=
Terminal=false
Name=JupyterNotebook
Exec="jupyter notebook" %f
Type=Application

But this did not work. Double-clicking on a .ipynb file still opens it in Chrome and shows the .json contents rather than running it as a notebook.

Has anybody actually gotten this functionality to work with Ubuntu 18.04?

cdahms
  • 1,773

1 Answers1

3

You have to enter the full path to the jupyter-notebook executable in the Exec field of your .desktop file.

You can find the full path of jupyter-notebook by running:

which jupyter-notebook

So your .desktop file would become:

[Desktop Entry]
Comment=
Terminal=false
Name=JupyterNotebook
Exec="/full/path/to/jupyter-notebook" %f
Type=Application

You also have to make your .desktop file executable, if you haven't already, by running:

chmod u+x ~/.local/share/applications/jupyter_notebook.desktop

Finally, right-click a .ipynb file, go to PropertiesOpen With → select JupyterNotebook from the list → Set as default.

  • 1
    I love you! I love you! Works perfectly. – cdahms Dec 23 '19 at 04:25
  • I've done all that but I'm not getting a "JupyterNotebook" option when I choose Open With, even after clicking "View All Applications". Tried logging out & back in, tried restarting Gnome shell still no effect. ? – sh37211 May 18 '20 at 01:50
  • ^Got it working. Ultimately I had to add a mime type to my system, and also define the mime type in the .desktop file. Then "JupyterNotebook" appeared on the list of available applications. Also used "nbopen" instead of main "jupyter" exec, just so it won't respawn new servers if not necessary. – sh37211 May 18 '20 at 02:11