Jupytext

Editing within Jupyter kinda sucks, the VSCode extension goes a long way, however, getting it to work reliably on anything other than vanilla Ubuntu LTS can be a hit and miss. Jupyter in Pycharm is ok but non-free and a bit rough with the vim extension.

Well I’ve been playing around with Jupytext which allows syncing a jupyter notebook with a python script and this is great! Check out this example:

Basic Usage

Take any file.ipynb and run jupytext --to py:percent file.ipynb, then pop open three termux tabs:

  1. watch make a Makefile that has build: jupytext --to ipynb --update *.py{.makefile}
  2. jupyter lab
  3. nvim myfile.py

This will preserve output in the jupyter notebook. If adding anything in the jupyter notebook just save with C-s.

Extension Magic

There is a jupyter nbextension to automate this:

jupyter nbextension install --py jupytext [--user]
jupyter nbextension enable --py jupytext [--user]

See Also