What are optional dependencies (extras)?
IntermediateConceptEnvironments, dependencies & packaging
Answer
Named groups of extra dependencies declared in [project.optional-dependencies], installed with pip install "pkg[extra]". We use dev for test and lint tools, and feature extras like moto[ec2,s3] or requests[socks] pull in only what a feature needs. Quote the argument in shells like zsh, where [ is a glob character (zsh: no matches found: .[dev]).
More on Environments, dependencies & packaging
What is a virtual environment and why do we always use one?BeginnerWhat does `error: externally-managed-environment` mean?Beginner`requirements.txt` vs `pyproject.toml`: what goes where?IntermediateWhy is `pip freeze > requirements.txt` not a great lock strategy?IntermediateWhat do version specifiers like `~=`, `==`, `>=,<` mean?BeginnerWhat are `pipx` and `uv`, and when do you use them?Intermediate