Jupyter extensions are a great way of increasing your productivity when using notebooks. In this post I will show how to install them and a configuration tool, as well as include information about some of my favourites and my personal configuration file.

Installation and configuration file

The code below shows how to install the extensions:

pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user

The configuration for the extensions is set in a json file (~/.jupyter/nbconfig/notebook.json). This means you can directly copy and paste them onto different machines (or into a docker container). Alternatively you can access the configuration tool by opening Jupyter and changing the tree part of the path to nbextensions (e.g. localhost:8888/nbextensions).

{
  "toc2": {
    "number_sections": false
  }, 
  "load_extensions": {
    "execute_time/ExecuteTime": true, 
    "toc2/main": true, 
    "select_keymap/main": false, 
    "notify/notify": true, 
    "autosavetime/main": true, 
    "hide_input_all/main": false, 
    "contrib_nbextensions_help_item/main": true
  }, 
  "autosavetime_set_starting_interval": true, 
  "autosavetime_starting_interval": "1"
}

My favourite extensions

toc2

As your notebooks get larger, this plugin becomes indispensible. It generates a floating or sidebar table of contents, with the sections determined using the markdown headers (#, ##, ### etc.). You can also have it automatically generate section numbering, but I find this annoying and have disabled it.

This also promotes properly setting heading levels whilst writing a notebook, which means you are always ready to export to a different format for your boss!

execute_time

When you are working with larger datasets, or on processing tasks that take a long time, this plugin becomes useful. It automatically monitors the amount of time each cell takes to run and displays that below the cell. This can be achieved using IPython magics (%%time), but it is nice to always have the output without having to re-run a cell.

notify

This saves you from the equivalent of watching paint dry! Once enabled, you can run a cell, and switch to a different task, the plugin will ping a desktop notification when the cell finishes processing. You can set the minimum amount of time a cell needs to take to run before generating a notification as well, so this doesn’t become annoying.

Fin

Jupyter notebook extensions are frankly amazing, and if you are using vanilla notebooks on a regular basis, you should definitely spend 5 minutes installing and testing them out. If you’re pushed for time, just use my configuration and you can watch your productivity improve massively.