{"record":{"id":"3f1d54a289810782","repo":"huggingface/smolagents","slug":"please-install-transformers-extra-to-use-a-pipel","errorCode":null,"errorMessage":"Please install 'transformers' extra to use a PipelineTool: `pip install 'smolagents[transformers]'`","messagePattern":"Please install 'transformers' extra to use a PipelineTool: `pip install 'smolagents\\[transformers\\]'`","errorType":"exception","errorClass":"ModuleNotFoundError","httpStatus":null,"severity":"error","filePath":"src/smolagents/tools.py","lineNumber":1231,"sourceCode":"    description = \"This is a pipeline tool\"\n    name = \"pipeline\"\n    inputs = {\"prompt\": str}\n    output_type = str\n    skip_forward_signature_validation = True\n\n    def __init__(\n        self,\n        model=None,\n        pre_processor=None,\n        post_processor=None,\n        device=None,\n        device_map=None,\n        model_kwargs=None,\n        token=None,\n        **hub_kwargs,\n    ):\n        if not _is_package_available(\"accelerate\") or not _is_package_available(\"torch\"):\n            raise ModuleNotFoundError(\n                \"Please install 'transformers' extra to use a PipelineTool: `pip install 'smolagents[transformers]'`\"\n            )\n\n        if model is None:\n            if self.default_checkpoint is None:\n                raise ValueError(\"This tool does not implement a default checkpoint, you need to pass one.\")\n            model = self.default_checkpoint\n        if pre_processor is None:\n            pre_processor = model\n\n        self.model = model\n        self.pre_processor = pre_processor\n        self.post_processor = post_processor\n        self.device = device\n        self.device_map = device_map\n        self.model_kwargs = {} if model_kwargs is None else model_kwargs\n        if device_map is not None:\n            self.model_kwargs[\"device_map\"] = device_map","sourceCodeStart":1213,"sourceCodeEnd":1249,"githubUrl":"https://github.com/huggingface/smolagents/blob/30bb1161095dbae2271e6bc3cc4c219cc3897a57/src/smolagents/tools.py#L1213-L1249","documentation":"PipelineTool (and its subclasses for transformers models) requires torch and accelerate at construction time. __init__ checks package availability and raises ModuleNotFoundError pointing at the 'transformers' extra when either is missing.","triggerScenarios":"Instantiating any PipelineTool subclass (e.g. a TransformersTool like a translation or VAD tool) in an environment lacking `torch` or `accelerate`. The check happens before any model download.","commonSituations":"Using smolagents tools that wrap transformers pipelines with only the base install; slim Docker images that exclude torch; CI environments where heavy ML deps are intentionally omitted.","solutions":["Install the extra: `pip install 'smolagents[transformers]'`","Or install the two required packages directly: `pip install torch accelerate`","For lightweight deployments, replace the PipelineTool with a Tool that calls a hosted inference API instead"],"exampleFix":"# before\ntool = SpeechToTextTool()  # ModuleNotFoundError\n# after  (after: pip install 'smolagents[transformers]')\ntool = SpeechToTextTool()","handlingStrategy":"validation","validationCode":"from smolagents.utils import _is_package_available\nif not (_is_package_available(\"torch\") and _is_package_available(\"accelerate\")):\n    raise SystemExit(\"Run: pip install 'smolagents[transformers]'\")\ntool = MyPipelineTool()","typeGuard":null,"tryCatchPattern":"try:\n    tool = MyPipelineTool()\nexcept ModuleNotFoundError as e:\n    if \"smolagents[transformers]\" in str(e):\n        print(\"transformers extra missing; skipping ML tool\")\n    else:\n        raise","preventionTips":["Install the transformers extra in environments using ML pipeline tools","Check torch/accelerate availability in startup health checks","Consider API-based tools in slim deployments"],"tags":["transformers","torch","accelerate","optional-dependency"],"backgroundTag":"missing-optional-dependency","analyzedSha":"30bb1161095dbae2271e6bc3cc4c219cc3897a57","analyzedAt":"2026-08-28T18:52:54.169Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}