{"record":{"id":"90d8ce2ca79fcb6f","repo":"huggingface/transformers","slug":"missing-requirements-in-your-local-environment-for","errorCode":null,"errorMessage":"Missing requirements in your local environment for `{path_or_repo_id}`:\n{newline-joined failed}","messagePattern":"Missing requirements in your local environment for `(.+?)`:\n(.+?)","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"src/transformers/dynamic_module_utils.py","lineNumber":848,"sourceCode":"            except importlib.metadata.PackageNotFoundError:\n                failed.append(f\"{requirement} (installed: None)\")\n                continue\n\n            if delimiter is not None and version_number is not None:\n                is_satisfied = VersionComparison.from_string(delimiter).value(\n                    version.parse(local_package_version), version.parse(version_number)\n                )\n            else:\n                is_satisfied = True\n\n            if not is_satisfied:\n                failed.append(f\"{requirement} (installed: {local_package_version})\")\n\n    except OSError:  # no requirements.txt\n        pass\n\n    if failed:\n        raise ImportError(\n            f\"Missing requirements in your local environment for `{path_or_repo_id}`:\\n\" + \"\\n\".join(failed)\n        )\n","sourceCodeStart":830,"sourceCodeEnd":851,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/dynamic_module_utils.py#L830-L851","documentation":"For models with a requirements.txt in the repo, check_python_requirements parses each requirement, compares it against the installed version (handling specifiers like >=X.Y), and collects failures. If any requirement is unmet the ImportError lists each one with the installed version, e.g. 'transformers>=4.40.0 (installed: 4.36.2)'.","triggerScenarios":"Loading a remote-code model whose repo ships requirements.txt where at least one line is unsatisfied — wrong installed version, missing package, or an unparsable local version string compared against a pinned specifier.","commonSituations":"Old transformers/torch versions in locked-down environments; new model repos tightening version pins after release; local installs with dev/non-standard version metadata that fail version.parse comparisons.","solutions":["pip install the listed packages at the listed minimum versions from the message.","Upgrade the environment (often upgrading transformers itself resolves it, since many repos pin transformers>=...).","If the comparison failed due to a weird local version, install a clean release of that package."],"exampleFix":"# before: ImportError 'transformers>=4.40.0 (installed: 4.36.2)'\npip install transformers==4.36.2\n\n# after\npip install -U 'transformers>=4.40.0'","handlingStrategy":"try-catch","validationCode":"from importlib.metadata import version, PackageNotFoundError\nfrom packaging.requirements import Requirement\n\ndef check_requirements(reqs: list[str]) -> list[str]:\n    failed = []\n    for r in reqs:\n        req = Requirement(r)\n        try:\n            v = version(req.name)\n        except PackageNotFoundError:\n            failed.append(r)\n            continue\n        if req.specifier and not req.specifier.contains(v, prereleases=True):\n            failed.append(f\"{r} (installed: {v})\")\n    return failed","typeGuard":null,"tryCatchPattern":"try:\n    AutoModel.from_pretrained(repo_id, trust_remote_code=True)\nexcept ImportError as e:\n    if \"Missing requirements\" in str(e):\n        raise SystemExit(f\"Upgrade environment per: {e}\")\n    raise","preventionTips":["Read the repo's requirements.txt before loading remote models.","Keep core deps (transformers, torch) current.","Verify environment parity between writer and loader machines."],"tags":["dependencies","requirements","trust-remote-code","environment"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}