Jupyter notebooks as Markdown documents, Julia, Python or R scripts
Project description
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
- Markdown files (or MyST Markdown files, or R Markdown documents)
- Scripts in many languages.
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
.
Please note that Jupytext includes an extension for Jupyter Lab. In the latest version of Jupytext, this extension is compatible with Jupyter Lab >= 3.0 only. If you use Jupyter Lab 2.x, please either stay with Jupytext 1.8.2, or install, on top of the latest pip or conda version of Jupytext, a version of the extension that is compatible with Jupyter Lab 2.x:
jupyter labextension install jupyterlab-jupytext@1.2.2 # For Jupyter Lab 2.x
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
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
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:
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file jupytext-1.11.2.tar.gz
.
File metadata
- Download URL: jupytext-1.11.2.tar.gz
- Upload date:
- Size: 683.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a32aa9edbc430653de3149de79c4ff4ee33ded2119b41ed476b5c93c9f6aff1 |
|
MD5 | 8336a6b58305e5d007dbaaed681e18ac |
|
BLAKE2b-256 | e4702160ef1ef6e87fc956a2fbab8b34acd29fca1405fa9ef8c6830a8336c02f |
File details
Details for the file jupytext-1.11.2-py3-none-any.whl
.
File metadata
- Download URL: jupytext-1.11.2-py3-none-any.whl
- Upload date:
- Size: 291.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 184e44c2ea91a85f323d8190bd13d9dfb3b73e8d2a92d239cf5e489c98ca3605 |
|
MD5 | b1d98c52d8cee2fa0045c03b14bed5e0 |
|
BLAKE2b-256 | a5d428b282c5f525d3e81c9db7a7566876d17708ad91cb8d8d0b534fc96f480a |