Managing packages
Installing a package
To install a package into the virtual environment, e.g., Flask:
To install a package with optional dependencies enabled, e.g., Flask with the "dotenv" extra:
To install multiple packages, e.g., Flask and Ruff:
To install a package with a constraint, e.g., Ruff v0.2.0 or newer:
To install a package at a specific version, e.g., Ruff v0.3.0:
To install a package from the disk:
To install a package from GitHub:
To install a package from GitHub at a specific reference:
$ # Install a tag
$ uv pip install "git+https://github.com/astral-sh/[email protected]"
$ # 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 changes to their source code to be active.
To install the current project as an editable package
To install a project in another directory as an editable package:
Installing packages from files
Multiple packages can be installed at once from standard file formats.
Install from a requirements.txt
file:
See the uv pip compile
documentation for more information on requirements.txt
files.
Install from a pyproject.toml
file:
Install from a pyproject.toml
file with optional dependencies enabled, e.g., the "foo" extra:
Install from a pyproject.toml
file with all optional dependencies enabled:
To install dependency groups in the current project directory's pyproject.toml
, for example the
group foo
:
To specify the project directory where groups should be sourced from:
Alternatively, you can specify a path to a pyproject.toml
for each group:
Note
As in pip, --group
flags do not apply to other sources specified with flags like -r
or -e.
For instance,
uv pip install -r some/path/pyproject.toml --group foosources
foofrom
./pyproject.tomland **not**
some/path/pyproject.toml`.
Uninstalling a package
To uninstall a package, e.g., Flask:
To uninstall multiple packages, e.g., Flask and Ruff: