Update Python packages with uv: project locks versus pip workflows

Published · Updated

Save

For a uv project with pyproject.toml and uv.lock, use uv lock --upgrade-package PACKAGE for a targeted resolution update or uv lock --upgrade for all packages within the declared constraints. Then sync and test. For a pip-style environment without a uv project, use uv pip install --upgrade PACKAGE. These workflows update different things.

Contents

Choose the command by what you maintain

Common update tasks
TaskCommandImportant boundary
Update one locked project dependencyuv lock --upgrade-package httpxUpdates the lockfile; still respects project constraints.
Update the project environment and resolutionuv sync --upgrade-package httpxUpdates the lock and environment together.
Upgrade all allowed project packagesuv lock --upgrade, then uv syncReview a potentially wider dependency change.
Upgrade a package in a pip-style environmentuv pip install --upgrade httpxDoes not establish a maintained project lockfile.
Refresh compiled requirementsuv pip compile requirements.in --upgrade -o requirements.txtCompilation and installation are separate steps.

A reviewable targeted project update

uv lock --upgrade-package httpx
# Review the pyproject/lockfile diff before applying it.
uv sync
# Run the test command appropriate to your own project.

The package name is an example, not a recommendation that every project needs that package or its latest release. If your declaration pins a version, an upgrade flag cannot silently ignore that requirement. Decide whether a constraint change is appropriate and review that change explicitly.

A targeted request can still move transitive dependencies when resolution requires it. Compare the complete lockfile diff, not only the requested package's version. Separate an update's installation success from its application compatibility.

Why ordinary sync may keep an older version

With an existing lockfile, uv normally prefers already locked versions that still satisfy the project's requirements. A newer upstream release does not by itself make that lockfile outdated. uv lock --check checks consistency with metadata; it does not mean “upgrade everything.”

--locked checks that the lockfile is current and refuses to update it. --frozen uses the existing lock without that consistency check. Those are reproducibility controls, not commands for fetching the newest compatible package. Standard uv run can lock/sync automatically; be deliberate in CI if you want changes to fail instead of modifying resolution.

Requirements files use another workflow

If requirements.in is your source, compile it to pinned output, review the output, then install or synchronize it according to your project's policy. An exact sync may remove packages that are not in the selected dependency set. Read the proposed command before applying it to an environment you share with other work.

For one targeted requirements update, use the compile command's --upgrade-package option rather than an unreviewed shell pipeline that upgrades every installed package. Installed packages can include temporary tools and dependencies that are not your application's intended requirements.

Verify the change and preserve a rollback path

  1. Start with a known code/lockfile version and preserve local changes.
  2. Review upstream release notes and relevant compatibility/security changes.
  3. Make the smallest useful dependency change, inspect the full diff and test the application behavior it can affect.
  4. Commit dependency declarations and the lockfile together when appropriate. Recover by restoring the previous reviewed files and syncing in a suitable environment—not by guessing old transitive versions.

The commands here were checked against current uv documentation. This article does not claim that an upgrade was performed on your environment or that a successful resolver run proves every dependency safe.

Sources and checking notes

Article history

Sources checked October 23, 2026

  • Removed stale claims that uv lacks a project-wide upgrade operation.
  • Separated project/uv.lock operations from the pip-compatible environment workflow and requirements compilation.
  • Added an original decision table and a review/rollback sequence; did not upgrade this repository.
Discuss this answer