Reputation: 4804
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?
Upvotes: 41
Views: 20304
Reputation: 643
Great answer by @sahuja for Mac users. A slight modification to have only one terminal opened:
if ps -e | grep "Python" | grep -v "grep" | grep -q "Jupyter/runtime"; then
/path/to/nbopen "$1"
else
variable="'$1'"
the_script='tell application "terminal" to do script "nbopen '
osascript -e "${the_script}${variable}\""
fi
Upvotes: 0
Reputation: 8900
To "promote" Yogesh's helpful comment to a fully self-contained answer:
In a CMD or PowerShell window with administrative rights (e.g. launched quickly with Win+X, then A), run:
pip install nbopen
python -m nbopen.install_win
Double-click on *.ipynb
files now starts a new server or reuses an existing instance.
Upvotes: 6
Reputation: 21
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.
Upvotes: 2
Reputation: 171
open Automator, create new Application
Run Shell Script
Pass input
to as arguments
variable="'$1'"
the_script='tell application "terminal" to do script "nbopen '
osascript -e "${the_script}${variable}\""
Save the new application to Applications
directory as nb_open
nb_open
in the Applications folder. Don't forget to check "Always Open With".command + i
) > Open With (select nb_open if not selected already) > Click Change All...
. Done.Upvotes: 13