pyobservablejs
pyobservablejs renders Observable JavaScript notebooks
from Python and connects the two runtimes. It does three things:
- Creates notebooks. Author Notebook Kit cells from Python, load existing Notebook Kit HTML, or import public observablehq.com notebooks.
- Moves values in both directions. Python variables drive the reactive graph in the browser, and rendered browser values synchronize back to Python.
- Exposes the dataflow graph. Python can inspect which cell defines each variable, follow dependency edges, and export Mermaid or D2 diagrams.
Each view is an anywidget, so notebooks render in any anywidget host: JupyterLab, marimo, VS Code notebooks, Google Colab, and others. The live examples on this site run in marimo.
Hover a dot to inspect a measurement. Plot and the penguins sample ship
with Notebook Kit.
import marimo as mo
import observablejs as obs
notebook = obs.Notebook(
obs.js(
"""
Plot.dot(penguins, {
x: "culmen_length_mm",
y: "culmen_depth_mm",
fill: "species",
r: 4,
tip: {fill: "var(--marimo-island-background)"}
}).plot({
height: 320,
color: {legend: true},
x: {grid: true, label: "Bill length (mm)"},
y: {grid: true, label: "Bill depth (mm)"}
})
"""
),
)
full_view = notebook.view()
mo.ui.anywidget(full_view)
Where to go next
Quickstart
Install pyobservablejs and render your first reactive notebook.
Mental model
Notebook, NotebookCell, and NotebookView: who owns what.
Connect Python and the browser
Drive the reactive graph from Python and read values back.
pyobservablejs or pyobsplot?
Choose the right tool for Observable-flavored work from Python.