Skip to main content

Jupyter notebooks as Markdown documents, Julia, Python or R scripts

Project description

CI Documentation Status codecov.io Language grade: Python Code style: black GitHub language count Conda Version Pypi pyversions Binder:notebook Binder:lab

FORK FOR EBP USE ONLY

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!

Jupytext is a plugin for Jupyter that can save Jupyter notebooks as either

Use cases

Common use cases for Jupytext are:

  • Doing version control on Jupyter Notebooks
  • Editing, merging or refactoring notebooks in your favorite text editor
  • Applying Q&A checks on notebooks.

Install

You can install Jupytext with

  • pip install jupytext
  • or conda install jupytext -c conda-forge.

Then, restart your Jupyter server (for more installation details, see the install section in the documentation).

When Jupytext is installed, .py and .md files have a notebook icon. And you can really open and run these files as notebooks

    With a click on the text file in Jupyter Notebook

    (click on the image above to try this on Binder)

    With a right click and open with notebook in Jupyter Lab

    (click on the image above to try this on Binder)

Paired notebooks

The most convenient way to use Jupytext is probably through paired notebooks.

To pair a given .ipynb or text notebook to an additional notebook format, use either

    the "pair notebook with..." commands in Jupyter Lab

    the "pair notebook with..." menu entries in Jupyter Notebook

    jupytext at the command line

    with e.g.

    jupytext --set-formats ipynb,py:percent notebook.ipynb
    

    see the documentation.

    or a local or global jupytext.toml configuration file.

    with e.g. the following content:

    default_jupytext_formats = "ipynb,py:percent"
    

    see the documentation.

When you save a paired notebook in Jupyter, both the .ipynb file and the text version are updated on disk.

When a paired notebook is opened or reloaded in Jupyter, the input cells are loaded from the text file, and combined with the output cells from the .ipynb file.

You can edit the text representation of the notebook in your favorite editor, and get the changes back in Jupyter by simply reloading the notebook (Ctrl+R in Jupyter Notebook, "reload notebook" in Jupyter Lab). And the changes are propagated to the .ipynb file when you save the notebook.

Alternatively, you can synchronise the two representations by running jupytext --sync notebook.ipynb at the command line.

Which text format?

Jupytext implements many text formats for Jupyter Notebooks. If your notebook is mostly made of code, you will probably prefer to save it as a script:

  • Use the percent format, a format with explicit cell delimiters (# %%), supported by many IDE (Spyder, Hydrogen, VS Code, PyCharm and PTVS)
  • Or use the light format, if you prefer to see fewer cell markers.

If your notebook contains more text than code, if you are writing a documentation or a book, you probably want to save your notebook as a Markdown document

  • Use the Jupytext Markdown format if you wish to render your notebook as a .md file (without its outputs) on GitHub
  • Use the MyST Markdown format, a markdown flavor that “implements the best parts of reStructuredText”, if you wish to render your notebooks using Sphinx or Jupyter Book.
  • Use the R Markdown format if you want to open your Jupyter Notebooks in RStudio.

More resources?

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

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

jupytext-ebp-1.7.2a0.tar.gz (660.4 kB view details)

Uploaded Source

Built Distribution

jupytext_ebp-1.7.2a0-py3-none-any.whl (305.3 kB view details)

Uploaded Python 3

File details

Details for the file jupytext-ebp-1.7.2a0.tar.gz.

File metadata

  • Download URL: jupytext-ebp-1.7.2a0.tar.gz
  • Upload date:
  • Size: 660.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.6.0.post20201009 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for jupytext-ebp-1.7.2a0.tar.gz
Algorithm Hash digest
SHA256 fc6d2b482fec3e83fa8e610d33a3a3009ba9c1d1628e1bab22dd3a631fd1eb82
MD5 273102dea525d6c0899649991ccd9045
BLAKE2b-256 28d36e44d8ad0e81c72cf386f4b1962de05e4730d72662e35bb2808d7c33360b

See more details on using hashes here.

File details

Details for the file jupytext_ebp-1.7.2a0-py3-none-any.whl.

File metadata

  • Download URL: jupytext_ebp-1.7.2a0-py3-none-any.whl
  • Upload date:
  • Size: 305.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.6.0.post20201009 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for jupytext_ebp-1.7.2a0-py3-none-any.whl
Algorithm Hash digest
SHA256 28db62c0caa696cf7a22b5cff35d52e8240bbd318392d3764344c292184864ba
MD5 b8d8bddebfa97046408668c70503cc52
BLAKE2b-256 a84416bf346edf72a2eeb52356c6c2ccf973728f69f8d5decf649625ee140024

See more details on using hashes here.

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