pypa/pip · error · CommandError
Options --outdated and --uptodate cannot be combined.
Error message
Options --outdated and --uptodate cannot be combined.
What it means
Raised as CommandError in ListCommand.run() at list.py:176-177 when both --outdated (-o) and --uptodate (-u) are passed. The two flags request opposite filters (packages that are behind vs. packages that are current), so combining them is logically meaningless and pip refuses rather than returning an empty or confusing result.
Source
Thrown at src/pip/_internal/commands/list.py:177
# Pass allow_yanked=False to ignore yanked versions.
selection_prefs = SelectionPreferences(
allow_yanked=False,
release_control=options.release_control,
format_control=options.format_control,
prefer_binary=options.prefer_binary,
)
return PackageFinder.create(
link_collector=link_collector,
selection_prefs=selection_prefs,
uploaded_prior_to=options.uploaded_prior_to,
)
def run(self, options: Values, args: list[str]) -> int:
cmdoptions.check_release_control_exclusive(options)
if options.outdated and options.uptodate:
raise CommandError("Options --outdated and --uptodate cannot be combined.")
if options.outdated and options.list_format == "freeze":
raise CommandError(
"List format 'freeze' cannot be used with the --outdated option."
)
cmdoptions.check_list_path_option(options)
packages: _ProcessedDists = [
cast("_DistWithLatestInfo", d)
for d in get_environment(options.path).iter_installed_distributions(
local_only=options.local,
user_only=options.user,
editables_only=options.editable,
include_editables=options.include_editable,
skip=set(stdlib_pkgs),
)
]View on GitHub (pinned to d7d0d0a394)
Solutions
- Use only one of --outdated or --uptodate depending on which set you want.
- If you want the full picture, run 'pip list' with neither flag and compare versions manually or via --format json.
- Run two separate commands and merge results in your script.
Example fix
# before pip list --outdated --uptodate # after pip list --outdated # or pip list --uptodate
Defensive patterns
Strategy: validation
Validate before calling
import sys
if '--outdated' in sys.argv or '-o' in sys.argv:
if '--uptodate' in sys.argv or '-u' in sys.argv:
print('ERROR: --outdated and --uptodate are mutually exclusive', file=sys.stderr)
sys.exit(2) Prevention
- Pass only one of --outdated / --uptodate.
- If you need both sets, run two separate 'pip list' invocations.
When it happens
Trigger: Running 'pip list -o -u' or 'pip list --outdated --uptodate'. The check at list.py:176 fires when both booleans are True.
Common situations: Combining flags while exploring; scripting that naively passes both; copy-paste from different command snippets.
Related errors
- List format 'freeze' cannot be used with the --outdated opti
- Can not combine '--user' and '--target'
- Can not combine '--user' and '--prefix' as they imply differ
- --require-hashes and --no-require-hashes are mutually exclus
- You must give at least one requirement to {name} (maybe you
AI-assisted analysis of pypa/pip@d7d0d0a394 (2026-08-04).
Data as JSON: /data/errors/ff1fa5cc48cf7381.json.
Report an issue: GitHub.