pyobservablejs brings reactive Observable notebooks
to Python. Build cells, charts, and browser inputs, or import an existing notebook.
Display the whole notebook or selected cells in JupyterLab, marimo, VS Code,
Colab, and other anywidget hosts.
Try it in your browser 路 Quickstart 路 Examples 路 API reference
Install in a Python 3.11 through 3.14 notebook environment:
pip install pyobservablejsCreate an input and a result that updates when it changes:
import observablejs as obs
notebook = obs.Notebook(
obs.ojs(
"viewof threshold = Inputs.range([0, 1], {value: 0.5, step: 0.1})",
key="control",
),
obs.js(
"const doubled = threshold * 2; display(md`Doubled: **${doubled}**`);",
key="result",
),
)
view = notebook.view()
viewCells run in the browser through Notebook Kit.
Its Inputs library loads from the network. Use notebook and module sources you
trust, since their JavaScript runs in the host page.
Experimental: the API may change between releases.
Install pyobservablejs[server] to inspect and evaluate notebooks in Python
scripts and services:
print(notebook.with_variables(threshold=0.5).data["doubled"].to_python())Read Python values, Polars or pandas dataframes, Arrow tables, and attachment bytes through the data and file namespaces. Headless Python guide.
- Compose views.
notebook.view("result")displays the result and evaluates its dependencies. Select and arrange cells. - Connect Python.
notebook.update_variables({"threshold": 0.8})updates mounted views. Read named results throughview.state. Send values and read results. - Bring notebooks and data. Load Notebook Kit HTML, public ObservableHQ notebooks, local files, and JavaScript modules. Create and import notebooks.
- Inspect and extract. Browse cells, imports, attachments, and dependencies. Read datasets as Arrow or projected rows. Inspect notebook data.
- Work with agents. The installed package carries instructions that match its API. Read the packaged skill or the documentation map.
Documentation 路 Troubleshooting 路 Contributing 路 MIT license
Built on Observable's Notebook Kit
and anywidget.
pyobsplot informed the Python variable API.
