{"record":{"id":"5e9cd7b455e87708","repo":"pypa/pip","slug":"unknown-command-cmd-name","errorCode":null,"errorMessage":"unknown command \"{cmd_name}\"","messagePattern":"unknown command \"(.+?)\"","errorType":"exception","errorClass":"CommandError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/cli/main_parser.py","lineNumber":130,"sourceCode":"        sys.stdout.write(os.linesep)\n        sys.exit()\n\n    # pip || pip help -> print_help()\n    if not args_else or (args_else[0] == \"help\" and len(args_else) == 1):\n        parser.print_help()\n        sys.exit()\n\n    # the subcommand name\n    cmd_name = args_else[0]\n\n    if cmd_name not in commands_dict:\n        guess = get_similar_commands(cmd_name)\n\n        msg = [f'unknown command \"{cmd_name}\"']\n        if guess:\n            msg.append(f'maybe you meant \"{guess}\"')\n\n        raise CommandError(\" - \".join(msg))\n\n    # all the args without the subcommand\n    cmd_args = args[:]\n    cmd_args.remove(cmd_name)\n\n    return cmd_name, cmd_args\n","sourceCodeStart":112,"sourceCodeEnd":137,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_internal/cli/main_parser.py#L112-L137","documentation":"Raised as CommandError by parse_command (main_parser.py:130) when the first non-option token is not a registered subcommand in commands_dict. Pip splits general options from the rest (line 81), takes args_else[0] as the subcommand (line 121), and at line 123 checks membership; on miss it calls get_similar_commands (line 124) to suggest a close match (e.g. 'install' for 'isntall'). The message lists the typo and, if available, a 'maybe you meant' hint.","triggerScenarios":"`pip isntall requests`, `pip instal requests`, or any misspelled/renamed subcommand.","commonSituations":"Typing pip commands quickly; using a subcommand that was removed or renamed in a newer pip; copy-pasting a command from docs that uses a different pip version's command name.","solutions":["Correct the subcommand spelling; run `pip help` to list valid commands.","If a 'maybe you meant' hint is shown, use the suggested command.","Upgrade/downgrade pip to match the documentation the command came from if a renamed command is involved."],"exampleFix":"# before\npip isntall requests\n# after\npip install requests","handlingStrategy":"validation","validationCode":"# Validate the subcommand against pip's registry before dispatching.\nfrom pip._internal.commands import commands_dict, get_similar_commands\ndef validate_subcommand(name):\n    if name not in commands_dict:\n        guess = get_similar_commands(name)\n        raise ValueError(f'unknown command \"{name}\"' + (f', did you mean \"{guess}\"?' if guess else ''))\n    return True","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Spell-check pip subcommands in scripts; run `pip help` to enumerate valid ones.","Pin pip version in CI so renamed/removed subcommands don't surprise you."],"tags":["cli-options","unknown-command","typo","command-error"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}