Skip to content

Instantly share code, notes, and snippets.

@magic-lantern
Created July 28, 2021 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magic-lantern/adef4499448e9ea295d90669ee7f9eaf to your computer and use it in GitHub Desktop.
Save magic-lantern/adef4499448e9ea295d90669ee7f9eaf to your computer and use it in GitHub Desktop.
Jupytext configuration

Jupytext setup (for *nix and Windows)

Installation

Run this command to install the jupytext extension:

conda install jupytext -c conda-forge

Start/restart jupyter. In the environment used to launch jupyter notebook you should now see the File > Jupytext menu. In jupyter lab, Jupytext adds a set of commands to the command palette (View / Activate Command Palette, or Ctrl+Shift+C):

Usage

You can use the pair command to associate the notebook file with a markdown version. That should be persistent for that specific notebook file.

File > Jupytext > Pair Notebook with Markdown

Configuration

To make it the default for all notebooks you open, you need to add a configuration file. On the versions of both Jupyter lab and Jupyter notebook that I have, this shows the directories where the configuration file can be stored:

from jupytext.config import global_jupytext_configuration_directories
list(global_jupytext_configuration_directories())

For me the above resulted in this:

['C:\\Users\\my username\\jupytext',
'C:\\Users\\my username',
'C:\\ProgramData\\jupytext',
'C:\\ProgramData']

So, I placed a text file at C:\Users\my username\jupytext\jupytext.toml with this contents:

# Always pair ipynb notebooks to md files
default_jupytext_formats = "ipynb,md"

See this for more details https://jupytext.readthedocs.io/en/latest/config.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment