uv.lock).
Usage
Description
Update the project’s lockfile. If the project lockfile (uv.lock) does not exist, it will be created. If a lockfile is present, its contents will be used as preferences for the resolution.
If there are no changes to the project’s dependencies, locking will have no effect unless the --upgrade flag is provided.
Options
Validation Options
--check
Check if the lockfile is up-to-date.Asserts that the
uv.lock would remain unchanged after a resolution. If the lockfile is missing or needs to be updated, uv will exit with an error.Equivalent to --locked.--locked
Check if the lockfile is up-to-date.Asserts that the
uv.lock would remain unchanged after a resolution. If the lockfile is missing or needs to be updated, uv will exit with an error.Equivalent to --check.Environment variable: UV_LOCKED--check-exists
Assert that a
uv.lock exists without checking if it is up-to-date.Equivalent to --frozen.Environment variable: UV_FROZEN--dry-run
Perform a dry run, without writing the lockfile.In dry-run mode, uv will resolve the project’s dependencies and report on the resulting changes, but will not write the lockfile to disk.
Script Options
Lock the specified Python script, rather than the current project.If provided, uv will lock the script (based on its inline metadata table, in adherence with PEP 723) to a
.lock file adjacent to the script itself.Python Options
The Python interpreter to use during resolution.A Python interpreter is required for building source distributions to determine package metadata when there are not wheels.The interpreter is also used as the fallback value for the minimum Python version if
Environment variable:
requires-python is not set.See uv help python for details on Python discovery and supported request formats.Short form: -pEnvironment variable:
UV_PYTHONExamples
Create or update the lockfile
uv.lock.
Check if lockfile is up-to-date
--check.
Verify lockfile exists
uv.lock exists without checking if it’s up-to-date.
Dry run
Lock a Python script
my_script.lock file adjacent to the script based on its PEP 723 inline metadata.
Lock with a specific Python version
Common Patterns
CI/CD: Ensure lockfile is current
Development: Preview lockfile changes
Upgrade dependencies
To upgrade dependencies, use the upgrade flags from the resolver:requests package.
Lock after adding dependencies
When you add dependencies viapyproject.toml directly:
uv add automatically updates the lockfile, so this is only needed when editing pyproject.toml manually.
Cross-platform lockfiles
Lockfiles are cross-platform by default. When you runuv lock, it creates a lockfile that works on all platforms (Linux, macOS, Windows) and all Python versions compatible with your requires-python constraint.
Monorepo: Lock entire workspace
uv.lock file.