pypa/pip · error · InstallationError
You must give at least one requirement to
Error message
You must give at least one requirement to {self.name} (see "pip help {self.name}") What it means
Raised by the uninstall command after all positional arguments and -r requirement files have been parsed, if reqs_to_uninstall is empty. This means pip was asked to uninstall nothing — either no args were given, every arg failed to parse into a named requirement, or all requirement files were empty.
Solutions
- Provide at least one package name: `pip uninstall <package>`.
- If using -r, ensure the requirements file is non-empty and contains valid package specifiers.
- Use `pip uninstall -y <package>` to avoid the confirmation prompt when scripting.
- If building the arg list dynamically, check it is non-empty before calling pip.
Example fix
# before pip uninstall # after pip uninstall -y requests
Defensive patterns
Strategy: validation
Validate before calling
def run_pip_uninstall(packages: list[str]) -> list[str]:
if not packages:
raise ValueError('pip uninstall requires at least one package name')
return ['pip', 'uninstall', '-y', *packages]
Prevention
- Check the package list is non-empty before invoking pip uninstall.
- Validate -r requirements files are non-empty before use.
When it happens
Trigger: Running `pip uninstall` with no arguments; passing requirement names that all fail to parse into a valid InstallRequirement.name (e.g. bare URLs with no project name); passing -r with an empty file or a file whose entries are all filtered out.
Common situations: Typing `pip uninstall` without a package name; scripts that pass an empty list or empty requirements file; passing a requirements.txt that contains only comments or invalid lines.
Related errors
- Missing required argument (search query).
- Key does not contain dot separated section and key. Perhaps…
- List format 'freeze' cannot be used with the --outdated…
- Needed a specific file to be modifying.
- Options --outdated and --uptodate cannot be combined.
AI-assisted analysis of pypa/pip@f399c37189 (2026-08-08).
Data as JSON: /api/errors/ad590039ed754080.
Report an issue: GitHub.
Appendix: source
Thrown at src/pip/_internal/commands/uninstall.py:92
reqs_to_uninstall[canonicalize_name(req.name)] = req
else:
logger.warning(
"Invalid requirement: %r ignored -"
" the uninstall command expects named"
" requirements.",
name,
)
for filename in options.requirements:
for parsed_req in parse_requirements(
filename, options=options, session=session
):
req = install_req_from_parsed_requirement(
parsed_req, isolated=options.isolated_mode
)
if req.name:
reqs_to_uninstall[canonicalize_name(req.name)] = req
if not reqs_to_uninstall:
raise InstallationError(
f"You must give at least one requirement to {self.name} (see "
f'"pip help {self.name}")'
)
if not options.override_externally_managed:
check_externally_managed()
protect_pip_from_modification_on_windows(
modifying_pip="pip" in reqs_to_uninstall
)
for req in reqs_to_uninstall.values():
uninstall_pathset = req.uninstall(
auto_confirm=options.yes,
verbose=self.verbosity > 0,
)
if uninstall_pathset:
uninstall_pathset.commit()View on GitHub (pinned to f399c37189)