{"record":{"id":"57615c13f8774e27","repo":"huggingface/smolagents","slug":"non-installed-authorized-modules-join-missi","errorCode":null,"errorMessage":"Non-installed authorized modules: {', '.join(missing_modules)}. Please install these modules or remove them from the authorized imports list.","messagePattern":"Non-installed authorized modules: (.+?)\\. Please install these modules or remove them from the authorized imports list\\.","errorType":"exception","errorClass":"InterpreterError","httpStatus":null,"severity":"error","filePath":"src/smolagents/local_python_executor.py","lineNumber":1742,"sourceCode":"        self.additional_functions = additional_functions or {}\n        self.timeout_seconds = timeout_seconds\n\n    def _check_authorized_imports_are_installed(self):\n        \"\"\"\n        Check that all authorized imports are installed on the system.\n\n        Handles wildcard imports (\"*\") and partial star-pattern imports (e.g., \"os.*\").\n\n        Raises:\n            InterpreterError: If any of the authorized modules are not installed.\n        \"\"\"\n        missing_modules = [\n            base_module\n            for imp in self.authorized_imports\n            if imp != \"*\" and find_spec(base_module := imp.split(\".\")[0]) is None\n        ]\n        if missing_modules:\n            raise InterpreterError(\n                f\"Non-installed authorized modules: {', '.join(missing_modules)}. \"\n                f\"Please install these modules or remove them from the authorized imports list.\"\n            )\n\n    def __call__(self, code_action: str) -> CodeOutput:\n        output, is_final_answer = evaluate_python_code(\n            code_action,\n            static_tools=self.static_tools,\n            custom_tools=self.custom_tools,\n            state=self.state,\n            authorized_imports=self.authorized_imports,\n            max_print_outputs_length=self.max_print_outputs_length,\n            timeout_seconds=self.timeout_seconds,\n        )\n        logs = str(self.state[\"_print_outputs\"])\n        return CodeOutput(output=output, logs=logs, is_final_answer=is_final_answer)\n\n    def send_variables(self, variables: dict[str, Any]):","sourceCodeStart":1724,"sourceCodeEnd":1760,"githubUrl":"https://github.com/huggingface/smolagents/blob/30bb1161095dbae2271e6bc3cc4c219cc3897a57/src/smolagents/local_python_executor.py#L1724-L1760","documentation":"Error \"Non-installed authorized modules: {', '.join(missing_modules)}. Please install these modules or remove them from the authorized imports list.\" thrown in huggingface/smolagents.","triggerScenarios":"Thrown at src/smolagents/local_python_executor.py:1742 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"from importlib.util import find_spec\nmissing = [m for m in my_imports if m != '*' and find_spec(m.split('.')[0]) is None]\nif missing:\n    raise SystemExit(f'Install first: pip install {\" \".join(missing)}')","typeGuard":"from importlib.util import find_spec\n\ndef all_imports_installed(authorized_imports: list[str]) -> bool:\n    return all(imp == '*' or find_spec(imp.split('.')[0]) is not None for imp in authorized_imports)","tryCatchPattern":"from smolagents.local_python_executor import InterpreterError\ntry:\n    executor = LocalPythonExecutor(authorized_imports)\nexcept InterpreterError as e:\n    if 'Non-installed authorized modules' in str(e):\n        subprocess.check_call([sys.executable, '-m', 'pip', 'install', *extract_modules(str(e))])","preventionTips":["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"],"tags":[],"backgroundTag":null,"analyzedSha":"30bb1161095dbae2271e6bc3cc4c219cc3897a57","analyzedAt":"2026-08-28T18:52:54.169Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}