{"record":{"id":"f940ca6c38a21c00","repo":"huggingface/transformers","slug":"type-self-name-requires-newer-versions-of","errorCode":null,"errorMessage":"{type(self).__name__} requires newer versions of: {', '.join(outdated)}","messagePattern":"(.+?) requires newer versions of: (.+?)","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"src/transformers/exporters/base.py","lineNumber":91,"sourceCode":"                installed_base = installed.split(\"+\", 1)[0]\n                tested_base = tested.split(\"+\", 1)[0]\n                if installed_base != tested_base:\n                    drift.append((pkg, installed_base, tested_base))\n\n        if missing:\n            specs = \", \".join(\n                f\"{pkg}=={self.tested_versions[pkg]}\" if pkg in self.tested_versions else pkg for pkg in missing\n            )\n            raise ImportError(f\"To use {type(self).__name__}, please install the following dependencies: {specs}\")\n\n        # Enforce hard minimums; collect all violations and report once, rather than failing on the first.\n        outdated = []\n        for pkg, minimum in self.min_versions.items():\n            _, installed = _is_package_available(pkg, return_version=True)\n            if installed == \"N/A\" or version.parse(installed.split(\"+\", 1)[0]) < version.parse(minimum):\n                outdated.append(f\"{pkg}>={minimum} (found {installed})\")\n        if outdated:\n            raise ImportError(f\"{type(self).__name__} requires newer versions of: {', '.join(outdated)}\")\n\n        if drift:\n            details = \", \".join(f\"{pkg}: installed {got}, tested {want}\" for pkg, got, want in drift)\n            logger.warning(\n                f\"{type(self).__name__} is experimental and patches many backend internals; \"\n                f\"behaviour may differ from what was validated. Version drift detected — {details}. \"\n                f\"If you hit issues, try the tested versions.\"\n            )\n\n    @abstractmethod\n    def export(\n        self,\n        model: PreTrainedModel,\n        sample_inputs: MutableMapping[str, torch.Tensor | Cache],\n        config: ExportConfigMixin,\n    ):\n        \"\"\"\n        Export the model and return the backend-specific program object.","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/exporters/base.py#L73-L109","documentation":"The same dependency guard raises ImportError when every required package is present but at least one is older than the hard minimum in the exporter's min_versions (e.g. DynamoExporter requires torch>=2.11.0). All violations are collected and reported in one message with the required minimum and the found version, so you can upgrade everything in a single step.","triggerScenarios":"Running DynamoExporter.export with torch 2.10 or older; ExecutorchExporter with an executorch below its minimum; the installed build is a pre-release whose version parses below the floor.","commonSituations":"Downgrading torch for another library and then trying to export; environment pinned by a training stack (torch 2.5) while the exporters need bleeding-edge torch; '+'-suffixed local builds where only the base version is compared.","solutions":["Upgrade each listed package to at least the stated minimum: pip install -U \"torch>=2.11.0\".","Prefer the tested version (e.g. torch==2.12.0) to also avoid the version-drift warning that follows.","If you cannot upgrade, use a different exporter backend whose min_versions your stack satisfies."],"exampleFix":"# before\nDynamoExporter().export(model, inputs, DynamoConfig())  # ImportError: torch>=2.11.0 (found 2.5.1)\n\n# after (shell)\n# pip install \"torch>=2.11.0\"\nDynamoExporter().export(model, inputs, DynamoConfig())","handlingStrategy":"validation","validationCode":"from packaging.version import Version\nimport torch\nfrom transformers.exporters.exporter_dynamo import DynamoExporter  # example\n\nfor pkg, minimum in DynamoExporter.min_versions.items():\n    installed = importlib.metadata.version(pkg)\n    assert Version(installed.split(\"+\")[0]) >= Version(minimum), f\"{pkg}>={minimum} required, found {installed}\"","typeGuard":null,"tryCatchPattern":"try:\n    DynamoExporter().export(model, inputs, cfg)\nexcept ImportError as e:\n    if \"requires newer versions\" in str(e):\n        raise SystemExit(\"Upgrade torch, then re-run: \" + str(e))\n    raise","preventionTips":["Pin torch to the exporter's tested_versions in your export environment","Add a version gate to CI so downgrades fail before the export job starts","Note only base versions (pre-'+' part) are compared — dev builds are judged by their base"],"tags":["export","dependencies","version-mismatch","environment"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}