pypa/pip · error · PylockUnsupportedVersionError

pylock version {pylock.lock_version} is not supported

Error message

pylock version {pylock.lock_version} is not supported

What it means

Raised as PylockUnsupportedVersionError (pylock.py:705), a subclass of PylockValidationError, when the parsed lock_version falls outside the supported range [1, 2). The check is `not (Version('1') <= lock_version < Version('2'))`, so 0.x, 2.x, or any non-1.x major version is rejected outright.

Source

Thrown at src/pip/_vendor/packaging/pylock.py:705

        object.__setattr__(self, "created_by", created_by)
        object.__setattr__(self, "packages", packages)
        object.__setattr__(self, "tool", tool)

    @classmethod
    def _from_dict(cls, d: Mapping[str, Any]) -> Self:
        pylock = cls(
            lock_version=_get_required_as(d, str, Version, "lock-version"),
            environments=_get_sequence_as(d, str, Marker, "environments"),
            extras=_get_sequence_as(d, str, _validate_normalized_name, "extras"),
            dependency_groups=_get_sequence(d, str, "dependency-groups"),
            default_groups=_get_sequence(d, str, "default-groups"),
            created_by=_get_required(d, str, "created-by"),
            requires_python=_get_as(d, str, SpecifierSet, "requires-python"),
            packages=_get_required_sequence_of_objects(d, Package, "packages"),
            tool=_get(d, Mapping, "tool"),  # type: ignore[type-abstract]
        )
        if not Version("1") <= pylock.lock_version < Version("2"):
            raise PylockUnsupportedVersionError(
                f"pylock version {pylock.lock_version} is not supported"
            )
        if pylock.lock_version > Version("1.0"):
            _logger.warning(
                "pylock minor version %s is not supported", pylock.lock_version
            )
        return pylock

    @classmethod
    def from_dict(cls, d: Mapping[str, Any], /) -> Self:
        """Create and validate a Pylock instance from a TOML dictionary.

        Raises :class:`PylockValidationError` if the input data is not
        spec-compliant.
        """
        return cls._from_dict(d)

    def to_dict(self) -> Mapping[str, Any]:

View on GitHub (pinned to d7d0d0a394)

Solutions

  1. Upgrade pip/packaging to a release that supports the lock_version you are reading.
  2. Downgrade/regenerate the lock file to lock-version = '1.x'.
  3. Confirm the lock-version field is present and correctly formatted; a missing/malformed value surfaces as a different error first.

Example fix

# before
lock-version = "2.0"

# after
lock-version = "1.0"
Defensive patterns

Strategy: try-catch

Validate before calling

from pip._vendor.packaging.version import Version
def is_supported_lock_version(v):
    return Version('1') <= Version(str(v)) < Version('2')

Type guard

null

Try / catch

from pip._vendor.packaging.pylock import PylockUnsupportedVersionError
try:
    Pylock.from_dict(d)
except PylockUnsupportedVersionError as e:
    upgrade_packaging_or_regenerate_lock(e)

Prevention

When it happens

Trigger: Pylock.from_dict() on a TOML whose lock-version is '2.0', '0.1', or '3'. Note: minor bumps above 1.0 (e.g. 1.1) only emit a logger.warning at pylock.py:709, they do NOT raise; only majors outside 1.x raise.

Common situations: A newer lock format (pylock v2) is published but this packaging version only supports v1. Conversely, an experimental/old draft lock with version 0.x. vendored packaging lagging behind the resolver that wrote the lock.

Related errors


AI-assisted analysis of pypa/pip@d7d0d0a394 (2026-08-04). Data as JSON: /data/errors/4cb94186c5122d79.json. Report an issue: GitHub.