{"record":{"id":"c2d818eee2475ef0","repo":"ultralytics/ultralytics","slug":"name-required-is-required-but-name-current","errorCode":null,"errorMessage":"{name}{required} is required, but {name}=={current} is currently installed {msg}","messagePattern":"(.+?)(.+?) is required, but (.+?)==(.+?) is currently installed (.+?)","errorType":"exception","errorClass":"ModuleNotFoundError","httpStatus":null,"severity":"error","filePath":"ultralytics/utils/checks.py","lineNumber":397,"sourceCode":"        op, version = re.match(r\"([^0-9]*)([\\d.]+)\", r).groups()  # split '>=22.04' -> ('>=', '22.04')\n        if not op:\n            op = \">=\"  # assume >= if no op passed\n        v = parse_version(version)  # '1.2.3' -> (1, 2, 3)\n        n = max(len(c), len(v))  # pad to equal length so 4-segment pins like '!=4.13.0.90' compare exactly\n        cn, vn = c + (0,) * (n - len(c)), v + (0,) * (n - len(v))\n        if (\n            (op == \"==\" and cn != vn)\n            or (op == \"!=\" and cn == vn)\n            or (op == \">=\" and not (cn >= vn))\n            or (op == \"<=\" and not (cn <= vn))\n            or (op == \">\" and not (cn > vn))\n            or (op == \"<\" and not (cn < vn))\n        ):\n            result = False\n    if not result:\n        warning = f\"{name}{required} is required, but {name}=={current} is currently installed {msg}\"\n        if hard:\n            raise ModuleNotFoundError(warning)  # assert version requirements met\n        if verbose:\n            LOGGER.warning(warning)\n    return result\n\n\ndef check_latest_pypi_version(package_name=\"ultralytics\"):\n    \"\"\"Return the latest version of a PyPI package without downloading or installing it.\n\n    Args:\n        package_name (str): The name of the package to find the latest version for.\n\n    Returns:\n        (str | None): The latest version of the package, or None if unavailable.\n    \"\"\"\n    import requests  # scoped as slow import\n\n    try:\n        requests.packages.urllib3.disable_warnings()  # Disable the InsecureRequestWarning","sourceCodeStart":379,"sourceCodeEnd":415,"githubUrl":"https://github.com/ultralytics/ultralytics/blob/0449ea011cfd6c9a0d50a0bf1043aca5190cd476/ultralytics/utils/checks.py#L379-L415","documentation":"Raised by the version-comparison branch of check_requirements() when an installed package is present but its version does not satisfy the required specifier (e.g. '>=1.8.0'). Each operator (==, !=, >=, <=, >, <) is evaluated against the installed version; on failure and hard=True a ModuleNotFoundError carrying the requirement string is raised. This guards against known-incompatible dependency versions at runtime.","triggerScenarios":"check_requirements('torch>=1.8.0') with torch 1.7 installed; export paths requiring e.g. 'nvidia-modelopt[onnx]>=0.44'; triton version pins on Windows/Linux. Triggered whenever the parsed operator comparison fails for the current environment.","commonSituations":"Old torch/numpy installations in frozen enterprise environments; version drift after a partial upgrade; downgrading one package without updating its dependents.","solutions":["Upgrade the offending package to satisfy the specifier: pip install -U 'package>=x.y'","Check the exact mismatch from the message (name==current vs required) and align your pins","For non-fatal probing use hard=False and handle the False return"],"exampleFix":"# before\n# torch 1.7 installed\ncheck_requirements('torch>=1.8.0', hard=True)  # ModuleNotFoundError\n\n# after\npip install -U 'torch>=1.8.0'\n# or soft-check:\nok = check_requirements('torch>=1.8.0', hard=False)","handlingStrategy":"validation","validationCode":"from ultralytics.utils.checks import check_requirements\n\nok = check_requirements('torch>=1.8.0', hard=False, verbose=False)\nif not ok:\n    raise SystemExit('upgrade torch: pip install -U torch')","typeGuard":"def version_satisfies(name: str, spec: str) -> bool:\n    \"\"\"True if installed package meets spec, without raising.\"\"\"\n    from importlib import metadata\n    from packaging.specifiers import SpecifierSet\n    try:\n        return metadata.version(name) in SpecifierSet(spec)\n    except metadata.PackageNotFoundError:\n        return False","tryCatchPattern":"try:\n    <ultralytics call>\nexcept ModuleNotFoundError as e:\n    if 'is required, but' in str(e):\n        print(f'version conflict: {e} — align your environment pins')\n    raise","preventionTips":["Upgrade the whole stack together (torch/numpy/ultralytics) rather than one package","Run a startup check_requirements([...], hard=False) sweep in long-lived services","Freeze a known-good environment after validating exports"],"tags":["dependencies","version","pip","environment"],"backgroundTag":null,"analyzedSha":"0449ea011cfd6c9a0d50a0bf1043aca5190cd476","analyzedAt":"2026-08-15T02:34:13.413Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}