34
votes

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?

3
"Double click" - are you using some GUI for your Linux? - Jongware
@Jongware, looks like there are some people out there now who prefer desktop environments over the pure command line interface. Really weird. - cel
The question you linked has a solution for ubuntu. Is this solution not working for you? - cel
@Jongware Are you using no GUI ? I'm using one - an offer can't refuse
@cel Everyone can't be geek (yet) and command lines may be a very freaking thing for many people. Nevertheless, python's notebook is a great tool to learn using python (which itself maybe a first step to be geek...). In that perspective, an easy opening mechanism for .ipynb files is essential to allow python's notebook to be used by a large audience. - jvtrudel

3 Answers

26
votes

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.

9
votes
  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.
1
votes

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. Win+X, A):

  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.