
Jupytext
CLI在 Jupyter Notebook 与普通 Python 脚本或 Markdown 之间互相转换、双向同步的工具,让 agent 能像改普通文本一样修改科研和教学用的 notebook,版本对比也更清楚。需要本机 Python 环境,用 pip 安装。
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 JupyterLab 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 JupyterLab.

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 JupyterLab 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.
💡 Tip: You can automate the notebook reloading by installing the Jupyter Collaboration extension.
To pair a notebook in JupyterLab, 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-oif 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
.ipynbnotebook in Jupyter and pair it to a.pynotebook, using either the pair command in JupyterLab, or a global configuration file - Save the notebook - this creates a
.pynotebook - Add this
.pynotebook 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
.pynotebook - They open it as a notebook in Jupyter (right-click in JupyterLab)
- At that stage the notebook has no outputs. They run the notebook and save it. Outputs are regenerated, and a local
.ipynbfile is created - They edit the notebook, and push the updated
notebook.pyfile. The diff is nothing else than a standard diff on a Python script. - You pull the updated
notebook.pyscript, and refresh your browser. The input cells are updated based on the new content ofnotebook.py. The outputs are reloaded from your local.ipynbfile. 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. Alternatively, the Jupyter Collaboration extension provides an autoreload feature which simplifies this.
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: .
Community
Have a question, a bug report, or an idea? Join us on Discord or open an issue or discussion on GitHub.
相關資源

Jupyter Notebooks
Skill创建、修改与校验可复现的 Python / SQL Jupyter Notebook:按分析报告或教程结构组织单元格,结论对照实际输出,交付前从头到尾执行一遍。OpenAI 官方维护,属于 openai/plugins 的 Data Analytics 插件。
openai/plugins7.5k
Jupyter MCP Server
MCP让 agent 实时连接 Jupyter Notebook:读写、插入与执行单元格,并读取图表等多模态输出,适合交互式数据分析。需自备 JupyterLab 或 JupyterHub,Datalayer 开源维护。
datalayer/jupyter-mcp-server1.3k
Jupyter Book
CLI把 Markdown 文档和 Jupyter 笔记本编成带目录、公式、参考文献与交叉引用的在线教材网站,也能导出出版级 PDF,常用于发布课程讲义。Jupyter 官方子项目,用 pipx 或 npm 安装;导出 PDF 需另装 Typst 或 LaTeX。
jupyter-book/jupyter-book4.3k
MATLAB MCP Server
MCPMathWorks 官方出品,让 agent 启动本机 MATLAB,编写并运行脚本和单元测试、检查代码风格与潜在错误,适合用 MATLAB 做数值计算、仿真和数据分析的工程师、科研人员与学生。需本机安装已授权的 MATLAB R2021a 以上,并下载服务器程序。
matlab/matlab-mcp-server1.7k
Quarto
CLIPosit 出品的开源科技出版系统,基于 Pandoc:在 Markdown 或 Jupyter 笔记本中嵌入 Python、R、Julia 代码,quarto render 生成 HTML、PDF、Word、幻灯片、网站与书籍。
quarto-dev/quarto-cli6.1k
Scientific Agent Skills
SkillK-Dense 维护的 166 个科研技能合集(原 Claude Scientific Skills):覆盖生物信息、化学信息、临床研究、材料与物理等领域,含统一查询 PubChem、UniProt 等 78 个公共数据库的技能。
K-Dense-AI/scientific-agent-skills51.2k
