Jupyter

I am trying to move some of my Jupyter projects closer to Obsidian, and I am looking for best practices.

Has anyone developed a good method to link them that is easy and quick, or a way to launch Anaconda/Jupyter with a link from Obsidian?

(older thread:)

1 Like

As far as I know (and that’s too little), there’s something called URIs. If Jupiter has some form of a URIs you can use it to link it into Obsidian.
They look like these obsidian://open?vault=VaultName&file=NewFile. This link will open a file called “NewFile” in the obsidian in the vault “VaultName” .

Similarly, you might have jupiter’s URIs.

Hi @elmsfeuer

Has anyone developed a good method to link them that is easy and quick, or a way to launch Anaconda/Jupyter with a link from Obsidian?

You can use Markdown link syntax:

[Link](file:///Users/dmitry/Documents/jupiter-notebook/lorenz.ipynb)

When clicking on the link Obsidian will delegate its handling to the OS. So the “tricky” part is to make your system to know how to open files with the .jpynb extension.

On macOS you can create an Automator workflow, save it as Application and point the OS to use it to open .jpyng files:

  1. Open Automator and drag “Run Shell Script” action into the workflow area

  2. Set “Pass input” option to “as arguments”.

  3. Paste in the following code:

     #!/bin/sh
     file="'$1'"
     scr='tell application "Terminal" to do script "jupyter notebook '
     osascript -e "${scr}${file}\""
    
  4. Save the workflow as “Jupyter Notebook” in your “Applications” folder and set “File Format” to “Application”.

  5. In the “Info” dialog to an .ipynb file set the “Open with” option to “Jupyter Notebook.app”. Click “Change All” and confirm the pop-up dialog.

On a Linux system you can create a shell script like this:

#!/bin/sh
jupyter notebook "$1"

make it executable and point the OS to use it to open .jpynb files (on MS Windows, I assume, you can create a similar .bat file instead).

Hope this helps.

3 Likes

OK, that’s a good solution for now. It’s a bit brittle (if the files are renamed or moved the links are broken), but it’s functional and easy.

Thanks!

@elmsfeuer

Here another one perhaps more clean solution for macOS:

  1. Open Automator and drag “Run AppleScript” action into the workflow area

  2. Paste in the following code:

     on run {input, parameters}
         set _file to POSIX path of input
         set _cmd to "jupyter notebook " & quoted form of _file
         tell application "Terminal" to do script _cmd
     end run
    
  3. Save the workflow as “Jupyter Notebook” in your “Applications” folder and set “File Format” to “Application”.

  4. In the “Info” dialog to an .ipynb file set the “Open with” option to “Jupyter Notebook.app”. Click “Change All” and confirm the pop-up dialog.

UPD: Added macOS icon:

jupyter.icns.zip (58.8 KB)

1 Like

Two issues with this:
*) the file:// needs an absolute path.
anybody know how to modify this so a relative path can be used instead?
*) this starts up a new jupyter server each time such a link is clicked.
any way to use an existing jupyter server instance?

@ea42gh

this starts up a new jupyter server each time such a link is clicked.
any way to use an existing jupyter server instance?

You can try to install the nbopen tool and replace the jupyter notebook command in the AppleScript code above with the nbopen command.

1 Like

Interesting! Unfortunatly, nbopen opens a jupyter notebook rather than jupyter lab!