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.

fix: check for __file__ on main (#1211)

Akshay Agrawal6f4f6f3bdb7f
diff --git a/marimo/_runtime/patches.py b/marimo/_runtime/patches.py
index 71af514a45..554a018e68 100644
--- a/marimo/_runtime/patches.py
+++ b/marimo/_runtime/patches.py
@@ -138,7 +138,7 @@ def patch_main_module(
if file is not None:
_module.__dict__.setdefault("__file__", file)
- else:
+ elif hasattr(sys.modules["__main__"], "__file__"):
_module.__dict__.setdefault(
"__file__", sys.modules["__main__"].__file__
)