marimo README
marimo-team/marimo · Apache-2.0 · 源码版本 ca559601
上手导读
安装与准备
安装 marimo 并打开编辑器,创建含数据、参数和图表的三个单元格。
试用示例
改变训练集比例,观察依赖它的指标与图形是否同步更新。
这是一款响应式的Python笔记本,具有优秀的可复现性,原生支持Git,并可作为脚本或应用程序部署。
用户手册 · Discord 社区 · 示例 · 展示廊 · YouTube
English | 繁體中文 | 简体中文 | 日本語 | Español
Marimo 是一款响应式 Python 笔记本:运行单元格可与 UI 元素交互,marimo 会自动更新依赖于它的单元格(或将其标记为过时单元格),从而保持代码和输出的一致性。marimo 笔记本以纯 Python 格式存储,可作为脚本执行,也可作为应用程序部署。
为什么选择 marimo
- 🚀 功能齐全:替代
jupyter、streamlit、jupytext、ipywidgets、papermill等更多工具 - ⚡️ 响应式:运行一个单元格,marimo会响应式地运行所有依赖单元格或将它们标记为过时
- 🖐️ 交互性:绑定滑块、表格、图表等UI元素到Python代码——无需回调函数
- 🐍 支持Git版本控制:笔记本以
.py文件格式存储 - 🛢️ 为数据设计:使用SQL查询数据框和数据库,过滤和搜索数据框
- 🤖 AI原生:与AI agent结对(如Claude Code),或使用编辑器的内置AI功能
- 🔬 可复现:无隐藏状态,确定性执行,内置包管理
- 🏃 可执行:作为Python脚本执行,通过命令行参数进行配置
- 🛜 可分享:部署为交互式Web应用或幻灯片,通过WASM在浏览器中运行
- 🧩 可复用: 可从一个笔记本导入函数和类到另一个笔记本
- 🧪 便于测试: 可在笔记本上运行 pytest
- ⌨️ 现代编辑器:GitHub Copilot、AI助手、vim快捷键、变量浏览器和更多功能
- 🧑💻 使用你喜爱的编辑器:在 VS Code 或 Cursor 或 PyCharm 中运行,或在 neovim、Zed 或任何其他文本编辑器中编辑
pip install marimo && marimo tutorial intro
在我们的在线体验平台试用marimo,完全在浏览器中运行!
跳转到快速入门了解我们的命令行工具。
响应式编程环境
Marimo 确保了您的代码、输出和程序的状态始的一致性,解决了与 Jupyter 等传统笔记本相关的许多问题。
独有的响应式设计 运行一个单元格,marimo 就会自动运行引用其变量的单元格,从而避免了手动重新运行单元格这一容易出错的工作。删除单元格,marimo 会从程序内存中删除其变量,消除隐藏状态。
兼容计算密集型笔记本。marimo允许您将运行时配置为延迟模式,将受影响的单元格标记为过时而不是自动运行它们。这既能保证程序状态的完整性,又能防止意外执行计算密集型单元格。
同步的UI元素。与UI元素如滑块、下拉菜单、数据框转换器和聊天界面交互时,使用它们的单元格会自动以最新值重新运行。
交互式数据框。分页浏览、搜索、过滤和排序数百万行数据,极速运行,无需编写代码。
高效运行时。marimo通过静态分析代码,只运行需要运行的单元格。
动态Markdown和SQL。使用Markdown创建依赖Python数据的动态文档。或者构建依赖Python值的SQL查询,并针对数据框、数据库、CSV、Google Sheets或其他数据源执行,使用我们内置的SQL引擎将结果作为Python数据框返回。
即使使用了Markdown或SQL,您的笔记本仍然是纯Python代码。
确定性执行顺序。笔记本按照基于变量引用而非单元格页面位置的确定性顺序执行。您可以根据想要讲述的故事组织笔记本。
内置包管理。marimo内置支持所有主要的包管理器,允许您在导入时安装包。marimo甚至可以序列化包依赖到笔记本文件中,并在隔离的venv沙箱中自动安装它们。
功能齐全。marimo集成了GitHub Copilot、AI助手、Ruff代码格式化、HTML导出、快速代码补全、VS Code扩展、PyCharm扩展、交互式数据框查看器和更多便捷功能。
快速起步
安装 在终端运行以下代码:
pip install marimo # or conda install -c conda-forge marimo
marimo tutorial intro要安装包含额外依赖项的版本(启用SQL单元格、AI补全等功能),运行:
pip install marimo[recommended]
创建新的笔记本
使用以下命令创建或编辑笔记本
marimo edit
运行应用 将笔记本作为Web应用运行,隐藏并锁定Python代码:
marimo run your_notebook.py
作为脚本执行 在命令行中将笔记本作为脚本执行:
python your_notebook.py
自动转换已有的 Jupyter 笔记本 通过命令行将 Jupyter 笔记本自动转换为 marimo 格式的笔记本
marimo convert your_notebook.ipynb > your_notebook.py对此,我们也有在线工具可供使用。
教程 列出所有的可用教程:
marimo tutorial --help
如果你有一些问题?
请参阅我们文档中的FAQ部分。
更多信息
Marimo 很容易上手,为高级用户提供了很大的空间。 例如,这是一个用 marimo 制作的 embedding 可视化工具 (示例视频):
|
|
|
|
|
| 教程 | 输入控件 | 绘图 | 布局 |
|
|
|
|
|
贡献
我们感谢所有人的贡献! 这是为所有人设计的工具,我们真挚的欢迎任何人的任何意见! 请参阅CONTRIBUTING.md 获取更多信息,了解如何参与到这个项目中来。
有问题?请在Discord上联系我们。
社区
我们也正在建设 marimo 社区,来和我们一起玩吧!
- 🌟 在GitHub上为我们点赞
- 💬 在Discord上与我们交流
- 📧 订阅我们的通讯
- ☁️ 加入我们的云服务候补名单
- ✏️ 在GitHub上开始讨论
- 🦋 在Bluesky上关注我们
- 🐦 在Twitter上关注我们
- 🎥 在YouTube上订阅
- 🕴️ 在LinkedIn上关注我们
愿景 ✨
marimo 是对 Python 笔记本的重塑,它是一个可复制、可交互、可共享的 Python 程序,而不是容易出错的 JSON 便笺。
我们相信,我们使用的工具会影响我们的思维方式--更好的工具,造就更好的思维。我们希望通过 marimo 为 Python 社区提供一个更好的编程环境,以便进行研究和交流;进行代码实验和分享;学习计算科学和教授计算科学。
我们的灵感来自于很多已有的项目, 特别是 Pluto.jl, ObservableHQ,和 Bret Victor's essays。 marimo 是向响应式数据流编程迈进的一大步。从 IPyflow,streamlit, TensorFlow, PyTorch, JAX,到 React,函数式、声明式和响应式编程的理念正在改善一系列工具。
原作者与许可证
文档来自 marimo-team/marimo 的上述提交,保留原文并调整了站内排版与链接。
查看仓库许可证原文 ↗
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.







