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: only add packages that we haven't already tried installing (#4089)

Akshay Agrawalf495b4538a90
diff --git a/marimo/_runtime/runtime.py b/marimo/_runtime/runtime.py
index b29146c186..ef26f2646f 100644
--- a/marimo/_runtime/runtime.py
+++ b/marimo/_runtime/runtime.py
@@ -1327,7 +1327,17 @@ class Kernel:
# from the errors
for e in module_not_found_errors:
if isinstance(e, ManyModulesNotFoundError):
- missing_packages.update(e.package_names)
+ # filter out packages that we already attempted to install
+ # to prevent an infinite loop
+ missing_packages.update(
+ {
+ package
+ for package in e.package_names
+ if not self.package_manager.attempted_to_install(
+ package
+ )
+ }
+ )
elif e.name is not None:
missing_modules.add(e.name)