uv/docs/pip/packages.md
Zanie Blue 1ee201da5a
Add structured documentation (#4426)
A ton of work remaining here, pushing so I can preview things rendered.

Here's the [latest rendered
documentation](https://astral-sh.github.io/uv/).
2024-06-26 11:28:42 -05:00

2.4 KiB

Managing packages

Installing a package

To install a package into the virtual environment, e.g., Flask:

uv pip install flask

To install a package with optional dependencies enabled, e.g., Flask with the "dotenv" extra:

uv pip install "flask[dotenv]"

To install multiple packages, e.g., Flask and Ruff:

uv pip install flask ruff

To install a package with a constraint, e.g., Ruff v0.2.0 or newer:

uv pip install 'ruff>=0.2.0'

To install a package at a specific version, e.g., Ruff v0.3.0:

uv pip install 'ruff==0.3.0'

To install a package from the disk:

uv pip install "ruff @ ./projects/ruff"

To install a package from GitHub:

uv pip install "git+https://github.com/astral-sh/ruff"

To install a package from GitHub at a specific reference:

# Install a tag
uv pip install "git+https://github.com/astral-sh/ruff@v0.2.0"

# Install a commit
uv pip install "git+https://github.com/astral-sh/ruff@1fadefa67b26508cc59cf38e6130bde2243c929d"

# Install a branch
uv pip install "git+https://github.com/astral-sh/ruff@main"

See the Git authentication documentation for installation from a private repository.

Editable packages

Editable packages do not need to be reinstalled for change to their source code to be active.

To install the current project as an editable package

uv pip install -e .

To install a project in another directory as an editable package:

uv pip install -e ruff @ ./project/ruff

Installing packages from files

Multiple packages can be installed at once from standard file formats.

Install from a requirements.txt file:

uv pip install -r requirements.txt

See the uv pip compile documentation for more information on requirements.txt files.

Install from a pyproject.toml file:

uv pip install -r pyproject.toml

Install from a pyproject.toml file with optional dependencies enabled, e.g., the "foo" extra:

uv pip install -r pyproject.toml --extra foo

Install from a pyproject.toml file with all optional dependencies enabled:

uv pip install -r pyproject.toml --all-extras

Uninstalling a package

To uninstall a package, e.g., Flask:

uv pip uninstall flask

To uninstall multiple packages, e.g., Flask and Ruff:

uv pip uninstall flask ruff