pypa/pip · error · InstallationError

You must give at least one requirement to {self.name} (see "

Error message

You must give at least one requirement to {self.name} (see "pip help {self.name}")

What it means

Raised as InstallationError in UninstallCommand.run() at uninstall.py:91-95 when, after parsing both positional package arguments and -r requirements files, the reqs_to_uninstall dict is empty. pip needs at least one named requirement to uninstall; it will not proceed with nothing to act on.

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 d7d0d0a394)

Solutions

  1. Add at least one package name: 'pip uninstall <package>'.
  2. Verify your -r file contains named 'package==version' lines, not just comments or URLs.
  3. If you passed requirement specifiers, ensure each has a name; check the 'Invalid requirement ... ignored' warnings printed above the error.
  4. Use 'pip uninstall --help' to confirm the expected argument syntax.

Example fix

# before
pip uninstall
# after
pip uninstall requests
Defensive patterns

Strategy: validation

Validate before calling

import sys, os
reqs = [a for a in sys.argv[1:] if not a.startswith('-')]
# also account for -r files
r_files = []
for i,a in enumerate(sys.argv):
    if a in ('-r','--requirement') and i+1 < len(sys.argv):
        r_files.append(sys.argv[i+1])
has_named_in_files = any(any(not l.startswith('#') and l.strip() for l in open(f)) for f in r_files if os.path.exists(f))
if not reqs and not has_named_in_files:
    print('ERROR: pip uninstall requires at least one package or a non-empty -r file', file=sys.stderr)
    sys.exit(2)

Prevention

When it happens

Trigger: Running 'pip uninstall' with no package args and no -r file; supplying only requirements files that are empty or contain no named requirements; supplying args that all fail to parse into named requirements (logged as warnings at uninstall.py:76-81 and then the dict is still empty).

Common situations: Typo leaving off the package name; a requirements file path that is empty or all comments; passing URL-only or unnamed requirement specifiers that produce no req.name.

Related errors


AI-assisted analysis of pypa/pip@d7d0d0a394 (2026-08-04). Data as JSON: /data/errors/ad590039ed754080.json. Report an issue: GitHub.