jupytext 1.17.2


pip install jupytext

  Latest version

Released: Jun 01, 2025


Meta
Author: Marc Wouts
Requires Python: >=3.9

Classifiers

Development Status
  • 5 - Production/Stable

Environment
  • Console

Framework
  • Jupyter
  • Jupyter :: JupyterLab :: 4
  • Jupyter :: JupyterLab :: Extensions
  • Jupyter :: JupyterLab :: Extensions :: Prebuilt

Intended Audience
  • Developers
  • Science/Research

License
  • OSI Approved :: MIT License

Programming Language
  • Python
  • Python :: 3
  • Python :: 3.9
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3.12
  • Python :: 3.13

Topic
  • Text Processing :: Markup

CI Documentation Status codecov.io MIT License Code style: black GitHub language count Conda Version Pypi pyversions Binder:lab Binder:notebook launch - renku Jupyter Con 2020

Jupytext

Have you always wished Jupyter notebooks were plain text documents? Wished you could edit them in your favorite IDE? And get clear and meaningful diffs when doing version control? Then, Jupytext may well be the tool you're looking for!

Text Notebooks

A Python notebook encoded in the py:percent format has a .py extension and looks like this:

# %% [markdown]
# This is a markdown cell

# %%
def f(x):
  return 3*x+1

Only the notebook inputs (and optionally, the metadata) are included. Text notebooks are well suited for version control. You can also edit or refactor them in an IDE - the .py notebook above is a regular Python file.

We recommend the percent format for notebooks that mostly contain code. The percent format is available for Julia, Python, R and many other languages.

If your notebook is documentation-oriented, a Markdown-based format (text notebooks with a .md extension) might be more appropriate. Depending on what you plan to do with your notebook, you might prefer the Myst Markdown format, which interoperates very well with Jupyter Book, or Quarto Markdown, or even Pandoc Markdown.

Installation

Install Jupytext in the Python environment that you use for Jupyter. Use either

pip install jupytext

or

conda install jupytext -c conda-forge

Then, restart your Jupyter Lab server, and make sure Jupytext is activated in Jupyter: .py and .md files have a Notebook icon, and you can open them as Notebooks with a right click in Jupyter Lab.

Notebook icon on text notebooks

Paired Notebooks

Text notebooks with a .py or .md extension are well suited for version control. They can be edited or authored conveniently in an IDE. You can open and run them as notebooks in Jupyter Lab with a right click. However, the notebook outputs are lost when the notebook is closed, as only the notebook inputs are saved in text notebooks.

A convenient alternative to text notebooks are paired notebooks. These are a set of two files, say .ipynb and .py, that contain the same notebook, but in different formats.

You can edit the .py version of the paired notebook, and get the edits back in Jupyter by selecting reload notebook from disk. The outputs will be reloaded from the .ipynb file, if it exists. The .ipynb version will be updated or recreated the next time you save the notebook in Jupyter.

To pair a notebook in Jupyter Lab, use the command Pair Notebook with percent Script from the Command Palette:

To pair all the notebooks in a certain directory, create a configuration file with this content:

# jupytext.toml at the root of your notebook directory
formats = "ipynb,py:percent"

Command line

Jupytext is also available at the command line. You can

  • pair a notebook with jupytext --set-formats ipynb,py:percent notebook.ipynb
  • synchronize the paired files with jupytext --sync notebook.py (the inputs are loaded from the most recent paired file)
  • convert a notebook in one format to another with jupytext --to ipynb notebook.py (use -o if you want a specific output file)
  • pipe a notebook to a linter with e.g. jupytext --pipe black notebook.ipynb

Sample use cases

Notebooks under version control

This is a quick how-to:

  • Open your .ipynb notebook in Jupyter and pair it to a .py notebook, using either the pair command in Jupyter Lab, or a global configuration file
  • Save the notebook - this creates a .py notebook
  • Add this .py notebook to version control

You might exclude .ipynb files from version control (unless you want to see the outputs versioned!). Jupytext will recreate the .ipynb files locally when the users open and save the .py notebooks.

Collaborating on notebooks with Git

Collaborating on Jupyter notebooks through Git becomes as easy as collaborating on text files.

Assume that you have your .py notebooks under version control (see above). Then,

  • Your collaborator pulls the .py notebook
  • They open it as a notebook in Jupyter (right-click in Jupyter Lab)
  • At that stage the notebook has no outputs. They run the notebook and save it. Outputs are regenerated, and a local .ipynb file is created
  • They edit the notebook, and push the updated notebook.py file. The diff is nothing else than a standard diff on a Python script.
  • You pull the updated notebook.py script, and refresh your browser. The input cells are updated based on the new content of notebook.py. The outputs are reloaded from your local .ipynb file. Finally, the kernel variables are untouched, so you have the option to run only the modified cells to get the new outputs.

Editing or refactoring a notebook in an IDE

Once your notebook is paired with a .py file, you can easily edit or refactor the .py representation of the notebook in an IDE.

Once you are done editing the .py notebook, you will just have to reload the notebook in Jupyter to get the latest edits there.

Note: It is simpler to close the .ipynb notebook in Jupyter when you edit the paired .py file. There is no obligation to do so; however, if you don't, you should be prepared to read carefully the pop-up messages. If Jupyter tries to save the notebook while the paired .py file has also been edited on disk since the last reload, a conflict will be detected and you will be asked to decide which version of the notebook (in memory or on disk) is the appropriate one.

More resources

Read more about Jupytext in the documentation.

If you're new to Jupytext, you may want to start with the FAQ or with the Tutorials.

There is also this short introduction to Jupytext: .

1.17.2 Jun 01, 2025
1.17.1 Apr 26, 2025
1.17.0 Apr 05, 2025
1.17.0rc2 Mar 26, 2025
1.17.0rc1 Mar 22, 2025
1.16.7 Feb 10, 2025
1.16.6 Dec 17, 2024
1.16.5 Dec 15, 2024
1.16.4 Jul 31, 2024
1.16.3 Jul 10, 2024
1.16.2 May 05, 2024
1.16.1 Jan 13, 2024
1.16.0 Dec 03, 2023
1.16.0rc0 Nov 28, 2023
1.15.2 Sep 16, 2023
1.15.1 Aug 26, 2023
1.15.0 Jul 30, 2023
1.15.0.dev2 Jul 28, 2023
1.15.0.dev1 Jul 18, 2023
1.14.7 Jun 30, 2023
1.14.6 Jun 04, 2023
1.14.5 Feb 25, 2023
1.14.4 Dec 11, 2022
1.14.3 Dec 11, 2022
1.14.2 Dec 05, 2022
1.14.1 Jul 29, 2022
1.14.0 Jul 03, 2022
1.13.8 Apr 04, 2022
1.13.7 Feb 09, 2022
1.13.6 Jan 11, 2022
1.13.5 Dec 27, 2021
1.13.4 Dec 12, 2021
1.13.3 Dec 04, 2021
1.13.2 Nov 30, 2021
1.13.1 Nov 08, 2021
1.13.0 Sep 25, 2021
1.12.0 Sep 08, 2021
1.11.5 Aug 31, 2021
1.11.4 Jul 14, 2021
1.11.3 Jun 10, 2021
1.11.2 May 02, 2021
1.11.1 Mar 25, 2021
1.11.0 Mar 18, 2021
1.10.3 Mar 07, 2021
1.10.2 Feb 17, 2021
1.10.2rc1 Feb 17, 2021
1.10.1 Feb 10, 2021
1.10.1rc0 Feb 10, 2021
1.10.0 Feb 04, 2021
1.9.1 Jan 06, 2021
1.9.0 Jan 05, 2021
1.8.2 Jan 04, 2021
1.8.1 Jan 03, 2021
1.8.0 Dec 22, 2020
1.7.1 Nov 16, 2020
1.7.0 Nov 14, 2020
1.7.0rc1 Nov 11, 2020
1.7.0rc0 Oct 05, 2020
1.6.0 Sep 01, 2020
1.6.0rc0 Aug 30, 2020
1.5.2 Jul 21, 2020
1.5.1 Jul 05, 2020
1.5.0 Jun 07, 2020
1.5.0rc4 May 28, 2020
1.5.0rc3 May 28, 2020
1.5.0rc2 May 28, 2020
1.5.0rc1 May 22, 2020
1.4.2 Apr 05, 2020
1.4.1 Mar 18, 2020
1.4.0 Mar 09, 2020
1.3.5 Mar 08, 2020
1.3.4 Feb 18, 2020
1.3.3 Jan 27, 2020
1.3.2 Jan 08, 2020
1.3.1 Dec 26, 2019
1.3.0 Nov 23, 2019
1.3.0rc2 Nov 14, 2019
1.3.0rc1 Nov 08, 2019
1.3.0rc0 Oct 13, 2019
1.2.4 Sep 19, 2019
1.2.3 Sep 02, 2019
1.2.2 Sep 01, 2019
1.2.1 Jul 20, 2019
1.2.0 Jul 17, 2019
1.2.0rc3 Jul 17, 2019
1.2.0rc2 Jul 09, 2019
1.2.0rc1 Jul 03, 2019
1.2.0rc0 Jul 03, 2019
1.1.7 Jun 23, 2019
1.1.7rc0 Jun 21, 2019
1.1.7.dev0 Jun 13, 2019
1.1.6 Jun 11, 2019
1.1.5 Jun 05, 2019
1.1.4 Jun 05, 2019
1.1.4rc1 May 27, 2019
1.1.4rc0 May 27, 2019
1.1.3 May 21, 2019
1.1.2 May 15, 2019
1.1.1 Apr 16, 2019
1.1.0 Apr 14, 2019
1.1.0rc2 Apr 11, 2019
1.1.0rc1 Apr 09, 2019
1.1.0rc0 Apr 02, 2019
1.0.5 Mar 25, 2019
1.0.4 Mar 19, 2019
1.0.3 Mar 13, 2019
1.0.2 Feb 27, 2019
1.0.1 Feb 23, 2019
1.0.1rc0 Feb 23, 2019
1.0.0 Feb 18, 2019
1.0.0rc5 Feb 16, 2019
1.0.0rc4 Feb 13, 2019
1.0.0rc3 Feb 08, 2019
1.0.0rc2 Feb 05, 2019
1.0.0rc1 Jan 31, 2019
1.0.0rc0 Jan 29, 2019
0.8.6 Nov 29, 2018
0.8.6rc1 Nov 27, 2018
0.8.6rc0 Nov 25, 2018
0.8.5 Nov 13, 2018
0.8.4 Oct 29, 2018
0.8.4rc1 Oct 25, 2018
0.8.4rc0 Oct 24, 2018
0.8.3 Oct 18, 2018
0.8.2 Oct 14, 2018
0.8.1 Oct 11, 2018
0.8.0 Oct 10, 2018
0.7.2 Sep 30, 2018
0.7.1 Sep 23, 2018
0.7.0 Sep 23, 2018
0.7.0rc1 Sep 23, 2018
0.7.0rc0 Sep 22, 2018
0.6.5 Sep 13, 2018
0.6.4 Sep 11, 2018
0.6.3 Sep 07, 2018
0.6.2 Sep 05, 2018
0.6.1 Aug 31, 2018

Wheel compatibility matrix

Platform Python 3
any

Files in release

Extras:
Dependencies:
markdown-it-py (>=1.0)
mdit-py-plugins
nbformat
packaging
pyyaml
tomli