Skip to main content
Remove dependencies from the project’s pyproject.toml.

Usage

uv remove [OPTIONS] <PACKAGES>...

Description

Remove dependencies from the project’s pyproject.toml file. If multiple entries exist for a given dependency (i.e., each with different markers), all of the entries will be removed. The lockfile and project environment will be updated to reflect the removed dependencies. To skip updating the lockfile, use --frozen. To skip updating the environment, use --no-sync. If any of the requested dependencies are not present in the project, uv will exit with an error. If a package has been manually installed in the environment (i.e., with uv pip install), it will not be removed by uv remove. uv will search for a project in the current directory or any parent directory. If a project cannot be found, uv will exit with an error.

Arguments

PACKAGES
string[]
required
The names of the dependencies to remove (e.g., ruff).Packages are specified by name, not as full PEP 508 requirements.

Options

Dependency Groups

--dev
Remove the packages from the development dependency group.This option is an alias for --group dev.Environment variable: UV_DEV
--optional
string
Remove the packages from the project’s optional dependencies for the specified extra.
--group
string
Remove the packages from the specified dependency group.

Syncing Options

--no-sync
Avoid syncing the virtual environment after re-locking the project.Environment variable: UV_NO_SYNC

Locking Options

--locked
Assert that the uv.lock will remain unchanged.Requires that the lockfile is up-to-date. If the lockfile is missing or needs to be updated, uv will exit with an error.Environment variable: UV_LOCKED
--frozen
Remove dependencies without re-locking the project.The project environment will not be synced.Environment variable: UV_FROZEN

Workspace Options

--package
string
Remove the dependencies from a specific package in the workspace.
--script
path
Remove the dependency from the specified Python script, rather than from a project.If provided, uv will remove the dependency from the script’s inline metadata table, in adherence with PEP 723.

Environment Options

--active
Prefer the active virtual environment over the project’s virtual environment.If the project virtual environment is active or no virtual environment is active, this has no effect.
--python
string
The Python interpreter to use for resolving and syncing.See uv help python for details on Python discovery and supported request formats.Short form: -p
Environment variable: UV_PYTHON

Examples

Remove a single package

uv remove requests

Remove multiple packages

uv remove requests urllib3 certifi

Remove a development dependency

uv remove --dev pytest

Remove from an optional dependency group

uv remove --optional docs sphinx

Remove from a custom dependency group

uv remove --group test pytest pytest-cov

Remove without syncing

uv remove --no-sync old-package
This removes the package from pyproject.toml and updates the lockfile, but doesn’t modify the environment. Run uv sync later to apply changes.

Remove from a workspace package

uv remove --package my-package requests

Remove from a Python script

uv remove --script my_script.py requests
Removes the dependency from the script’s PEP 723 inline metadata.

Remove with frozen lockfile

uv remove --frozen old-package
Removes the package without updating the lockfile or environment.

Common Patterns

Clean up unused dependencies

# Remove packages one by one
uv remove package1 package2 package3

Remove all test dependencies

uv remove --dev pytest pytest-cov pytest-mock black ruff

Remove optional dependencies

uv remove --optional docs sphinx sphinx-rtd-theme

Batch removal without environment sync

uv remove --no-sync pkg1 pkg2 pkg3
uv remove --no-sync --dev test-pkg1 test-pkg2
uv sync  # Apply all changes at once
  • uv add - Add dependencies to the project
  • uv sync - Sync the project environment
  • uv lock - Update the project lockfile
  • uv tree - Display dependency tree

Build docs developers (and LLMs) love