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.

Add guard around click import for WASM (#1224)

Dylan Madisetti9295c99d301a
diff --git a/marimo/_server/export/exporter.py b/marimo/_server/export/exporter.py
index 5f47239703..af10a3692d 100644
--- a/marimo/_server/export/exporter.py
+++ b/marimo/_server/export/exporter.py
@@ -5,8 +5,6 @@ import mimetypes
import os
from typing import cast
-from click import UsageError
-
from marimo import __version__
from marimo._config.config import (
DEFAULT_CONFIG,
@@ -23,6 +21,15 @@ from marimo._server.session.session_view import SessionView
from marimo._server.templates.templates import static_notebook_template
from marimo._utils.paths import import_files
+# Click not bound to be installed (e.g. pyodide).
+try:
+ from click import UsageError
+except ImportError:
+
+ class UsageError(Exception): # type: ignore[no-redef]
+ pass
+
+
# Root directory for static assets
root = os.path.realpath(str(import_files("marimo").joinpath("_static")))