{"record":{"id":"d0b189586ead4b60","repo":"sgl-project/sglang","slug":"pkg-with-minimum-required-version-min-version","errorCode":null,"errorMessage":"{pkg} with minimum required version {min_version} is not installed. {message}","messagePattern":"(.+?) with minimum required version (.+?) is not installed\\. (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/utils/common.py","lineNumber":2132,"sourceCode":"    return (\n        pkg in _KERNEL_VERSION_CHECK_PACKAGES\n        and envs.SGLANG_SKIP_SGL_KERNEL_VERSION_CHECK.get()\n    )\n\n\ndef assert_pkg_version(pkg: str, min_version: str, message: str):\n    if _should_skip_kernel_pkg_version_check(pkg):\n        return\n\n    try:\n        installed_version = version(pkg)\n        if pkg_version.parse(installed_version) < pkg_version.parse(min_version):\n            raise Exception(\n                f\"{pkg} is installed with version {installed_version}, which \"\n                f\"is less than the minimum required version {min_version}. \" + message\n            )\n    except PackageNotFoundError:\n        raise Exception(\n            f\"{pkg} with minimum required version {min_version} is not installed. \"\n            + message\n        )\n\n\ndef check_pkg_version_at_least(pkg: str, min_version: str) -> bool:\n    \"\"\"\n    Check if a package is installed and meets the minimum version requirement.\n\n    Args:\n        pkg: Package name (distribution name, e.g., \"flashinfer-python\")\n        min_version: Minimum version required (e.g., \"0.6.17\")\n\n    Returns:\n        True if package is installed and version >= min_version, False otherwise\n    \"\"\"\n    if _should_skip_kernel_pkg_version_check(pkg):\n        return True","sourceCodeStart":2114,"sourceCodeEnd":2150,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/utils/common.py#L2114-L2150","documentation":"The same dependency guard as 6363 but for the missing-package branch: importlib.metadata.version(pkg) raised PackageNotFoundError, so the required package is not installed at all.","triggerScenarios":"Fresh install where the optional/required kernel package (sgl-kernel, flashinfer, etc.) was never installed, or was uninstalled.","commonSituations":"'lite'/CPU installation variants, broken venvs, Docker images built without the CUDA kernel wheels.","solutions":["pip install <pkg>>=<min_version>","If using a slim install, switch to the full sglang[srt_cuda] extra or the official Docker image","Verify with pip show <pkg> that it is visible in the active environment"],"exampleFix":"// before\n# package missing entirely\n// after\npip install 'sgl-kernel>=0.0.5'","handlingStrategy":"validation","validationCode":"from importlib.metadata import version\nversion(pkg)  # raises PackageNotFoundError if absent -> install before proceeding","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install the full sglang CUDA extra or the official Docker image","Add pip check / import smoke tests to container builds"],"tags":["dependencies","missing-package","packaging"],"backgroundTag":"missing-dependency","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}