Skip to main content

Strips outputs from Jupyter and IPython notebooks

Project description

Opens a notebook, strips its output, and writes the outputless version to the original file.

Useful mainly as a git filter or pre-commit hook for users who don’t want to track output in VCS.

This does mostly the same thing as the Clear All Output command in the notebook UI.

Based on


Strip output from IPython / Jupyter notebook (modifies the files in-place):

nbstripout FILE.ipynb [FILE2.ipynb ...]

Force processing of non .ipynb files:

nbstripout -f FILE.ipynb.bak

Use as part of a shell pipeline:

FILE.ipynb | nbstripout > OUT.ipynb

Set up the git filter and attributes as described in the manual installation instructions below:

nbstripout install

Show this help page:

nbstripout help

Manual filter installation

Set up a git filter using nbstripout as follows:

git config filter.nbstripout.clean '/path/to/nbstripout'
git config filter.nbstripout.smudge cat
git config filter.nbstripout.required true

Create a file .gitattributes or .git/info/attributes with:

*.ipynb filter=nbstripout

Mercurial usage

Mercurial does not have the equivalent of smudge filters. One can use an encode/decode hook but this has some issues. An alternative solution is to provide a set of commands that first run nbstripout, then perform there operations. This is the approach of the [mmf-setup package]( which uses the 0.2.x branch of nbstripout:

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nbstripout-0.2.0.tar.gz (3.2 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page