Trying to read a .ipynb file without starting a jupyter server? jut has you covered.

watch the video version of this post on YouTube

install

jut is packaged and available on pypi so installing is as easy as pip installing it.


pip install jut

installing jut with pip

! This is my first time including snippets of the video in the article like this, let me know what you think!

examples


jut https://cantera.org/examples/jupyter/thermo/flame_temperature.ipynb
jut https://cantera.org/examples/jupyter/thermo/flame_temperature.ipynb --head 3
jut https://cantera.org/examples/jupyter/thermo/flame_temperature.ipynb --tail 2

running jut examples

what are all the commands available for jut?

Take a look at the help of the jut cli to explore all the options that it offers.


jut --help

There is some good information on the projects readme as well.

getting help with jut

without installing

using pipx

Don't want jut cluttering up your venv, or want to save yourself from making a new one, pipx can manage a separate virual environment for you. This is one of the biggest selling points for me.


pipx run jut https://cantera.org/examples/jupyter/thermo/flame_temperature.ipynb --head 3

running jut with pipx

nbconvert

jut is the lightweight option that I think will fit the bill often for me, but it just doesn't always cut it. Mostly if there are images in the notebook or large output that is hard to read, its time to pull out the medium guns that sit between fulling running jupyter and jut.


pip install nbconvert

nbconvert does not have its own cli, instead it sits under the jupyter command.

converting to html

Need to see images, go here!


wget https://cantera.org/examples/jupyter/thermo/flame_temperature.ipynb
jupyter nbconvert flame_temperature.ipynb --to html
python -m http.server

Note, nb convert does not work with a url, you will need to have the notebook locally.

nbconvert to html to see images

what other options does nbconvert offer?

nbconvert also offers a standard help flag that you can access by passing in the --help flag


jupyter nbconvert --help

converting to markdown

nbconvert also supports converting to many other formats, one option that is quite interesting for use in the terminal is markdown. We could simply convert the notebook to markdown and cat it out.


jupyter nbconvert flame_temperature.ipynb --to maarkdown
cat flameflame_temperature.md

nbconvert to markdown and displaying in bat

viewing markdown with glow

Glow is a terminal markdown viewer that looks really good. These days I use bat as cat so I don't get quite as much benefit from glow, but it still looks pretty good.


glow flameflame_temperature.md

nbconvert to markdown and displaying in glow

viewing markdown as slides with lookatme

lookatme

Lookatme is my slideshow tool of choice. Creating slides in markdown is such a fantasic user experience, It realy lets you go from outline to finished slide deck fluidly. Refactoring the whole thing is also so much easier than with gui tools. Once you have your idea fleshed out it does make the process of making slides in powerpoint much easier if thats what you need.

On to nbconvert, without even changing the notebook we can look at the notebook as a slideshow in the terminal. The only thing that it needs is some markdown headers to start new slides from.


lookatme flameflame_temperature.md

nbconvert to markdown and displaying as slides with lookatme

viewing markdown with rich

Bringing this full circle, lets take a look at the converted markdown with rich. Here you will notice a surprising similarity to what we saw with jut.


pip install rich
python -m rich.markdown flame_temperature.md

Rich still cannot pull directly from a url or display markdown with out being installed and managed by yourself. Unlike how jut can leverage pipx to manage the installation sandbox for you.

  • jut - View notebooks in the terminal
  • nbconvert - convert notebooks to other formats
  • flame-temperature notebook - The sample notebook I used
  • glow - Terminal Markdown viewer
  • lookatme - Terminal Markdown slideshow tool
  • pipx - Run python cli's without maintianing a virtual environment
  • rich - Beautiful python terminal formatter