Skip to content

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.

Improve: error message for missing 'mo' name (#7169)

Akshay Agrawal8eb875a9d1cb
diff --git a/frontend/src/components/editor/output/MarimoErrorOutput.tsx b/frontend/src/components/editor/output/MarimoErrorOutput.tsx
index a025988c44..22d5ac4194 100644
--- a/frontend/src/components/editor/output/MarimoErrorOutput.tsx
+++ b/frontend/src/components/editor/output/MarimoErrorOutput.tsx
@@ -386,23 +386,45 @@ export const MarimoErrorOutput = ({
if (exceptionErrors.length > 0) {
messages.push(
<ul key="exception">
- {exceptionErrors.map((error, idx) => (
- <li className="my-2" key={`exception-${idx}`}>
- {error.raising_cell == null ? (
- <div>
- <p className="text-muted-foreground">{error.msg}</p>
- <div className="text-muted-foreground mt-2">
- See the console area for a traceback.
+ {exceptionErrors.map((error, idx) => {
+ if (
+ error.exception_type === "NameError" &&
+ error.msg.startsWith("name 'mo'")
+ ) {
+ return (
+ <li className="my-2" key={`exception-${idx}`}>
+ <div>
+ <p className="text-muted-foreground">
+ name 'mo' is not defined.
+ </p>
+ <p className="text-muted-foreground mt-2">
+ The marimo module (imported as{" "}
+ <Kbd className="inline">mo</Kbd>) is required for
+ Markdown, SQL, and UI elements.
+ </p>
</div>
- </div>
- ) : (
- <div>
- {error.msg}
- <CellLinkError cellId={error.raising_cell as CellId} />
- </div>
- )}
- </li>
- ))}
+ </li>
+ );
+ }
+
+ return (
+ <li className="my-2" key={`exception-${idx}`}>
+ {error.raising_cell == null ? (
+ <div>
+ <p className="text-muted-foreground">{error.msg}</p>
+ <div className="text-muted-foreground mt-2">
+ See the console area for a traceback.
+ </div>
+ </div>
+ ) : (
+ <div>
+ {error.msg}
+ <CellLinkError cellId={error.raising_cell as CellId} />
+ </div>
+ )}
+ </li>
+ );
+ })}
{exceptionErrors.some((e) => e.raising_cell != null) && (
<Tip>
Fix the error in the mentioned cells, or handle the exceptions