Skip to main content

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

Project description

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

Build Status Documentation Status codecov.io Language grade: Python

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 can save Jupyter notebooks as

  • Markdown and R Markdown documents,
  • Julia, Python, R, Bash, Scheme, Clojure, Matlab, Octave, C++, q/kdb+ and IDL scripts.

It can also convert these documents into Jupyter Notebooks, allowing you to synchronize content in both directions.

For more complete information try the jupytext documentation!

Try Jupytext

Introducing Jupytext PyParis Binder

Looking for a demo?

Installation

Conda Version Pypi pyversions

Jupytext is available on pypi and on conda-forge. Run either of

pip install jupytext --upgrade

or

conda install -c conda-forge jupytext

If you want to use Jupytext within Jupyter Notebook or JupyterLab, make sure you install Jupytext in the Python environment where the Jupyter server runs. If that environment is read-only, for instance if your server is started using JupyterHub, install Jupytext in user mode with:

/path_to_your_jupyter_environment/python -m pip install jupytext --upgrade --user

Jupytext's contents manager

Jupytext includes a contents manager for Jupyter that allows Jupyter to open and save notebooks as text files. When Jupytext's content manager is active in Jupyter, scripts and Markdown documents have a notebook icon.

If you don't have the notebook icon on text documents after a fresh restart of your Jupyter server, install the contents manager manually. Append

c.NotebookApp.contents_manager_class = "jupytext.TextFileContentsManager"

to your .jupyter/jupyter_notebook_config.py file (generate a Jupyter config, if you don't have one yet, with jupyter notebook --generate-config). Our contents manager accepts a few options: default formats, default metadata filter, etc. Then, restart Jupyter Notebook or JupyterLab, either from the JupyterHub interface or from the command line with

jupyter notebook # or lab

Jupytext menu in Jupyter Notebook

Jupytext includes an extensions for Jupyter Notebook that adds a Jupytext section in the File menu.

Jupyter notebook extension

If the extension was not automatically installed, install and activate it with

jupyter nbextension install --py jupytext [--user]
jupyter nbextension enable --py jupytext [--user]

Jupytext commands in JupyterLab

In JupyterLab, Jupytext adds a set of commands to the command palette:

JupyterLab extension

If you don't see these commands, install the extension manually with

jupyter labextension install jupyterlab-jupytext

(the above requires npm, run conda install nodejs first if you don't have npm).

Using Jupytext

Paired notebooks in the Jupyter Server

Jupytext can write a given notebook to multiple files. In addition to the original notebook file, Jupytext can save the input cells to a text file — either a script or a Markdown document. Put the text file under version control for a clear commit history. Or refactor the paired script, and reimport the updated input cells by simply refreshing the notebook in Jupyter.

Configuring notebooks to use Jupytext

Select the pairing for a given notebook using either the Jupytext menu in Jupyter Notebook, or the Jupytext commands in JupyterLab.

Alternatively, the pairing information for one or multiple notebooks can be set on the command line:

jupytext --set-formats ipynb,py [--sync] notebook.ipynb

For more information see the jupytext documentation.

Command line conversion

The package provides a jupytext script for command line conversion between the various notebook extensions:

jupytext --to py notebook.ipynb                 # create a notebook.py file in the light format
jupytext --to notebook notebook.py              # overwrite notebook.ipynb (remove outputs)
jupytext --update --to notebook notebook.py     # update notebook.ipynb (preserve outputs and metadata)

For more examples, see the jupytext documentation

Want to contribute?

Contributions are welcome. Please let us know how you use jupytext and how we could improve it. You think the documentation could be improved? Go ahead! Read our CONTRIBUTING.md to find out guidelines and instructions on how to setup a development environment. And stay tuned for more demos on medium and twitter!

Project details


Release history Release notifications | RSS feed

This version

1.1.4

Download files

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

Source Distribution

jupytext-1.1.4.tar.gz (78.4 kB view details)

Uploaded Source

File details

Details for the file jupytext-1.1.4.tar.gz.

File metadata

  • Download URL: jupytext-1.1.4.tar.gz
  • Upload date:
  • Size: 78.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for jupytext-1.1.4.tar.gz
Algorithm Hash digest
SHA256 3886f84668983066d002a60ef26f05f8485e3cb2b8320f4e93a00d297dc5994d
MD5 0a5fa7ed47fe2fe459547125bc8ecea9
BLAKE2b-256 e141c6f67452bf6f7d3cd131016d3a1b9a41b6871062ab144187ec3497437bc8

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