How to add a Jupyter Notebook icon to my app menu?

I am working on Jupyter Notebook and I want to see its icon in the Applications menu, but it is not there. I should also mention that I do not have Anaconda, and I installed Jupyter separately.
Also its location is:

~/.local/bin/jupyter-notebook

I run this for using Jupyter every time.

Asked By: Zeus

||

To add a Jupyter Notebook launcher to start a Jupyter notebook from the applications menu do the following:

  1. Create a jupyter-notebook.desktop file in ~/.local/share/applications:

    touch ~/.local/share/applications/jupyter-notebook.desktop
    
  2. Open the file with a text editor (I’m using nano):

    nano ~/.local/share/applications/jupyter-notebook.desktop
    
  3. Add the following to the file:

    [Desktop Entry]
    Comment=Open a Jupyter Notebook in your browser
    Terminal=false
    Name=JupyterNotebook
    Exec="/full/path/to/jupyter-notebook"
    Icon="/full/path/to/custom/icon"
    Type=Application
    

    Note that in the Exec and Icon fields you have to use the full path to jupyter-notebook and the custom icon you want to use for the launcher. So in your case you should add something like /home/user/.local/bin/jupyter-notebook instead of ~/.local/bin/jupyter-notebook in Exec, where user is your actual username. Similarly for Icon.

  4. Save and close the file (Ctrl+O and then Ctrl+X in nano).

That’s it! You should now be able to run Jupyter Notebook from your applications menu.


Note: Every time you open a Jupyter Notebook this way, a new Jupyter server will be launched as well, although without being shown in a terminal. If you close the browser tab that Jupyter Notebook runs in, the server will continue to run. So you’ll have to close the server yourself. To do that you can use the jupyter notebook list command in a terminal, which will list all running servers, and then you’ll have tot use jupyter notebook stop port, where port is the port that localhost runs on.

For example, I have started three Jupyter Notebooks using the applications menu launcher and I have closed the browser tabs. jupyter notebook list shows:

Currently running servers:
http://localhost:8889/?token=23b2468a3229ca7a18430cd48039fd95e0e6866d2a8cd5d5 :: /home/user
http://localhost:8888/?token=406937f75d9e564986d0e1c7929a9119c95eeff01b5bcca8 :: /home/user
http://localhost:8890/?token=2fa24c5385fe7dc4d0fc91cf267cff029571614e272f8453 :: /home/user

To close them I have to run:

jupyter notebook stop 8889
jupyter notebook stop 8888
jupyter notebook stop 8890
Answered By: BeastOfCaerbannog
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.