huggingface/smolagents · error · InterpreterError
Non-installed authorized modules: {', '.join(missing_modules
Error message
Non-installed authorized modules: {', '.join(missing_modules)}. Please install these modules or remove them from the authorized imports list. What it means
Error "Non-installed authorized modules: {', '.join(missing_modules)}. Please install these modules or remove them from the authorized imports list." thrown in huggingface/smolagents.
Source
Thrown at src/smolagents/local_python_executor.py:1742
self.additional_functions = additional_functions or {}
self.timeout_seconds = timeout_seconds
def _check_authorized_imports_are_installed(self):
"""
Check that all authorized imports are installed on the system.
Handles wildcard imports ("*") and partial star-pattern imports (e.g., "os.*").
Raises:
InterpreterError: If any of the authorized modules are not installed.
"""
missing_modules = [
base_module
for imp in self.authorized_imports
if imp != "*" and find_spec(base_module := imp.split(".")[0]) is None
]
if missing_modules:
raise InterpreterError(
f"Non-installed authorized modules: {', '.join(missing_modules)}. "
f"Please install these modules or remove them from the authorized imports list."
)
def __call__(self, code_action: str) -> CodeOutput:
output, is_final_answer = evaluate_python_code(
code_action,
static_tools=self.static_tools,
custom_tools=self.custom_tools,
state=self.state,
authorized_imports=self.authorized_imports,
max_print_outputs_length=self.max_print_outputs_length,
timeout_seconds=self.timeout_seconds,
)
logs = str(self.state["_print_outputs"])
return CodeOutput(output=output, logs=logs, is_final_answer=is_final_answer)
def send_variables(self, variables: dict[str, Any]):View on GitHub (pinned to 30bb116109)
Solutions
- Install the missing modules with pip/pip3 (e.g. pip install module_name)
- Remove the non-installed modules from the authorized imports list if they are not needed
- Pre-install the authorized modules in the execution environment image so the check passes
Defensive patterns
Strategy: validation
Validate before calling
from importlib.util import find_spec
missing = [m for m in my_imports if m != '*' and find_spec(m.split('.')[0]) is None]
if missing:
raise SystemExit(f'Install first: pip install {" ".join(missing)}') Type guard
from importlib.util import find_spec
def all_imports_installed(authorized_imports: list[str]) -> bool:
return all(imp == '*' or find_spec(imp.split('.')[0]) is not None for imp in authorized_imports) Try / catch
from smolagents.local_python_executor import InterpreterError
try:
executor = LocalPythonExecutor(authorized_imports)
except InterpreterError as e:
if 'Non-installed authorized modules' in str(e):
subprocess.check_call([sys.executable, '-m', 'pip', 'install', *extract_modules(str(e))]) Prevention
- Declare authorized-import modules in requirements/pyproject
- Run find_spec checks at startup in CI and container builds
- Only list modules actually installed in the target environment
When it happens
Trigger: Thrown at src/smolagents/local_python_executor.py:1742 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of huggingface/smolagents@30bb116109 (2026-08-28).
Data as JSON: /api/errors/57615c13f8774e27.
Report an issue: GitHub.