sgl-project/sglang · error · Exception

{pkg} with minimum required version {min_version} is not ins

Error message

{pkg} with minimum required version {min_version} is not installed. {message}

What it means

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.

Source

Thrown at python/sglang/srt/utils/common.py:2132

    return (
        pkg in _KERNEL_VERSION_CHECK_PACKAGES
        and envs.SGLANG_SKIP_SGL_KERNEL_VERSION_CHECK.get()
    )


def assert_pkg_version(pkg: str, min_version: str, message: str):
    if _should_skip_kernel_pkg_version_check(pkg):
        return

    try:
        installed_version = version(pkg)
        if pkg_version.parse(installed_version) < pkg_version.parse(min_version):
            raise Exception(
                f"{pkg} is installed with version {installed_version}, which "
                f"is less than the minimum required version {min_version}. " + message
            )
    except PackageNotFoundError:
        raise Exception(
            f"{pkg} with minimum required version {min_version} is not installed. "
            + message
        )


def check_pkg_version_at_least(pkg: str, min_version: str) -> bool:
    """
    Check if a package is installed and meets the minimum version requirement.

    Args:
        pkg: Package name (distribution name, e.g., "flashinfer-python")
        min_version: Minimum version required (e.g., "0.6.17")

    Returns:
        True if package is installed and version >= min_version, False otherwise
    """
    if _should_skip_kernel_pkg_version_check(pkg):
        return True

View on GitHub (pinned to 0132848349)

Solutions

  1. pip install <pkg>>=<min_version>
  2. If using a slim install, switch to the full sglang[srt_cuda] extra or the official Docker image
  3. Verify with pip show <pkg> that it is visible in the active environment

Example fix

// before
# package missing entirely
// after
pip install 'sgl-kernel>=0.0.5'
Defensive patterns

Strategy: validation

Validate before calling

from importlib.metadata import version
version(pkg)  # raises PackageNotFoundError if absent -> install before proceeding

Prevention

When it happens

Trigger: Fresh install where the optional/required kernel package (sgl-kernel, flashinfer, etc.) was never installed, or was uninstalled.

Common situations: 'lite'/CPU installation variants, broken venvs, Docker images built without the CUDA kernel wheels.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/d0b189586ead4b60. Report an issue: GitHub.