double click to open an ipython notebook

Question:

Related posts: Open an ipython notebook via double-click on osx

How can I open Ipython notebook from double click? I always cd to the directory of the notebook, then type ipython notebook in the browser and then open it in the browser. This steps is very inconvenient.

In windows, I remembered that I can change the directory in the browser, but in linux there is no way to explore to other directory via browser, if I want to open a new book in another directory, I have to restart another kernel as above, which annoys me.

Is there any simple and verified way to do this?

Answers:

You can use a project like nbopen that handle that and will open the browser on the right notebook + start an IPython server if one is not yet running.

Answered By: Matt
  1. pip install nbopen.
  2. open Automator, create new Application

    • Drag’n drop Run Shell Script
    • Change Pass input to as arguments
    • Copy/paste this script:
    variable="'$1'"
    the_script='tell application "terminal" to do script "nbopen '
    osascript -e "${the_script}${variable}""
    
  3. Save the new application to Applications directory as nb_open

  4. Right click any ipynb file and select “Open with > Other” and select the nb_open in the Applications folder. Don’t forget to check “Always Open With”.
  5. Select an ipynb file, get info (command + i) > Open With (select nb_open if not selected already) > Click Change All.... Done.
Answered By: sahuja

To "promote" Yogesh’s helpful comment to a fully self-contained answer:

Windows 10

In a CMD or PowerShell window with administrative rights (e.g. launched quickly with Win+X, then A), run:

  1. pip install nbopen
  2. python -m nbopen.install_win
  3. Profit!

Double-click on *.ipynb files now starts a new server or reuses an existing instance.

Answered By: ojdo

One way to open a Jupyter notebook directly by double-clicking on the file is to associate the .ipynb file extension with the jupyter-notebook command. Here’s how to do it on a Windows system:

Right-click on the Jupyter notebook file that you want to open.
Select "Open with" and then choose "Choose another app".
Select "More apps" and then scroll down to the bottom and choose "Look for another app on this PC".
Navigate to the directory where the jupyter-notebook.exe file is located (usually in the Scripts subdirectory of your Python installation), and select it.
Check the box next to "Always use this app to open .ipynb files" and then click on "OK".
Now, when you double-click on an IPython notebook file, it should open directly in the Jupyter notebook.

On a Mac or Linux system, you can set the default application for .ipynb files by using the xdg-mime command. First, determine the full path to the jupyter-notebook executable:

which jupyter-notebook

This will return the path to the executable. Then, use the xdg-mime command to set the default application for .ipynb files:

xdg-mime default jupyter-notebook.desktop application/x-ipynb+json

Replace jupyter-notebook.desktop with the path to the jupyter-notebook executable that you determined earlier. Now, when you double-click on an IPython notebook file, it should open directly in the Jupyter notebook.

Answered By: Harshpal singh
Categories: questions 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.