{"id":"a3c6eb7d8e298811","repo":"pypa/pip","slug":"unknown-command-cmd-name-maybe-you-meant-g","errorCode":null,"errorMessage":"unknown command \"{cmd_name}\" - maybe you meant \"{guess}\"","messagePattern":"unknown command \"(.+?)\" - maybe you meant \"(.+?)\"","errorType":"exception","errorClass":"CommandError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/cli/main_parser.py","lineNumber":129,"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":111,"sourceCodeEnd":136,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_internal/cli/main_parser.py#L111-L136","documentation":"Raised by parse_command() in main_parser.py:129 when the first non-option argument is not a recognized pip subcommand. The error includes a 'did you mean?' suggestion from get_similar_commands() using fuzzy matching (difflib) against the known commands_dict. If no close match is found, the suggestion portion is omitted.","triggerScenarios":"Calling `pip instal foo` (typo for 'install'), `pip donwload foo` (typo for 'download'), `pip freese` (typo for 'freeze'), or any unrecognized first argument that isn't a valid pip command.","commonSituations":"Typos in pip subcommands. Using a command from a different package manager (e.g., `pip add` from npm/yarn). Running an older pip that doesn't have a newer command. Shell autocompletion inserting the wrong command.","solutions":["Check the spelling against known commands: `pip help` lists all commands.","If a suggestion is given, use the suggested command.","Update pip to the latest version if the command might be new."],"exampleFix":"# before\npip instal numpy\n\n# after\npip install numpy","handlingStrategy":"validation","validationCode":"from difflib import get_close_matches\nKNOWN_COMMANDS = ['install', 'download', 'uninstall', 'freeze', 'list', 'show', 'search', 'wheel', 'hash', 'completion', 'help', 'index', 'inspect']\ndef validate_command_name(name):\n    if name in KNOWN_COMMANDS:\n        return True\n    matches = get_close_matches(name, KNOWN_COMMANDS, n=1, cutoff=0.6)\n    return False, (matches[0] if matches else None)","typeGuard":null,"tryCatchPattern":"from pip._internal.exceptions import CommandError\ntry:\n    # pip <cmd> ...\nexcept CommandError as e:\n    if 'unknown command' in str(e):\n        # parse suggestion and retry with corrected command\n","preventionTips":["Run `pip help` to see available commands.","Use shell autocompletion for pip subcommands.","Validate user-provided command names before passing to pip."],"tags":["cli","command-not-found","typo","did-you-mean"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}