Understanding errors¶
marimo imposes a few constraints on your notebook code:
- no multiply defined variables: each variable can be defined in only one cell
- no cycles: if one cell declares variable
a
and readsb
, then another cannot declareb
and reada
. - no
import *
: importing all symbols from a library is not allowed
Why these constraints?
These constraints let marimo work its magic, making your notebooks:
- reproducible, with a well-defined execution order, no hidden state, and no hidden bugs;
- executable as a script;
- interactive with UI elements that work without callbacks;
- shareable as a web app, with far better performance that streamlit.
As a bonus, you'll find that you end up with cleaner, reusable code.
When a cell violates any of these constraints, marimo doesn't run it and instead reports an error. In these guides, we explain these errors and provide tips for how to work around them.
These errors might be surprising at first, but spend just a bit of time with marimo and adhering to these constraints will become second nature — and you'll get used to writing error-free code by default.
Guide | Description |
---|---|
Multiple definitions | How to deal with variables defined in multiple cells |
Import * |
Why you can't use import * |
Cycles | How to resolve cycle errors |
setup | How to enable top level definitions |