A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Session snapshots
Run notebooks and write their serialized session snapshots.
Export from the command line
marimo export session notebook.py
By default, snapshots are written to:
<notebook_dir>/__marimo__/session/<notebook_filename>.json
For example, exporting notebook.py writes:
__marimo__/session/notebook.py.json
Export a directory
marimo export session accepts one positional target: a notebook file or a directory.
To process multiple notebooks, pass a directory target.
Export every notebook in a directory:
marimo export session folder/
Passing CLI args
Pass CLI args through to notebooks with --:
marimo export session notebook.py -- --foo 123
Staleness and force overwrite
By default, marimo only rewrites session snapshots when they are stale (for example, when notebook code changes or PEP 723 script metadata changes). Up-to-date snapshots are skipped.
To force rewriting all snapshots, even when they are up-to-date:
marimo export session folder/ --force-overwrite
Error handling
If one notebook fails, marimo continues by default and exits non-zero after processing all targets.
Use --no-continue-on-error to stop at the first failure.
Sandboxed execution
To execute in a sandboxed environment, install
uv or
pixi, then pass --sandbox:
marimo export session notebook.py --sandbox
--sandbox defaults to uv. Use --sandbox uv or --sandbox pixi (equivalently,
--sandbox=uv or --sandbox=pixi) to select
the backend explicitly; only the selected tool needs to be installed.
Use --no-sandbox to disable sandboxing and dependency prompts.
Each notebook executes in a separate process using its inline dependencies, whether you export a single file or a directory. Up-to-date snapshots are skipped before checking for the backend or preparing the notebook environment.