I have some jupyter notebooks (ipynb) on a server, which I connected to with ssh. I can run them using ipython
. However, if I want to view or edit them, for example using vim
, it shows me the source code of the file (something like json).
I would like to know if there is any tool or command to view and edit them in terminal?
Advertisement
Answer
Jupytext can synchronize a ipynb
and a corresponding py
file using the following command:
jupytext --set-formats ipynb,py notebook.ipynb
Then after you edited the py
file, to reflect the changes to the ipynb
file you need to run the following command:
jupytext --sync notebook.ipynb
And then you can run the ipynb
using ipython
However, you could create a bash file to sync and run the file after it was edited:
fname="$PWD"/"$1".ipynb jupytext --sync $fname ipython $fname
you can give it an alias
and run it from any directory.