{"id":"75ff532f7fe3fd0c","repo":"pypa/pip","slug":"could-not-find-style-module-mod-r","errorCode":null,"errorMessage":"Could not find style module {mod!r}","messagePattern":"Could not find style module (.+?)","errorType":"exception","errorClass":"ClassNotFound","httpStatus":null,"severity":"error","filePath":"src/pip/_vendor/pygments/styles/__init__.py","lineNumber":47,"sourceCode":"    Will raise :exc:`pygments.util.ClassNotFound` if no style of that name is\n    found.\n    \"\"\"\n    if name in _STYLE_NAME_TO_MODULE_MAP:\n        mod, cls = _STYLE_NAME_TO_MODULE_MAP[name]\n        builtin = \"yes\"\n    else:\n        for found_name, style in find_plugin_styles():\n            if name == found_name:\n                return style\n        # perhaps it got dropped into our styles package\n        builtin = \"\"\n        mod = 'pygments.styles.' + name\n        cls = name.title() + \"Style\"\n\n    try:\n        mod = __import__(mod, None, None, [cls])\n    except ImportError:\n        raise ClassNotFound(f\"Could not find style module {mod!r}\" +\n                            (builtin and \", though it should be builtin\")\n                            + \".\")\n    try:\n        return getattr(mod, cls)\n    except AttributeError:\n        raise ClassNotFound(f\"Could not find style class {cls!r} in style module.\")\n\n\ndef get_all_styles():\n    \"\"\"Return a generator for all styles by name, both builtin and plugin.\"\"\"\n    for v in STYLES.values():\n        yield v[1]\n    for name, _ in find_plugin_styles():\n        yield name\n","sourceCodeStart":29,"sourceCodeEnd":62,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_vendor/pygments/styles/__init__.py#L29-L62","documentation":"Raised by get_style_by_name when __import__ of the resolved style module raises ImportError. For builtin names the message adds 'though it should be builtin', indicating a corrupt/incomplete pygments install; for custom names it means no such style module exists.","triggerScenarios":"get_style_by_name('nonexistent'), a typo'd style name, or a builtin style whose submodule is missing from a broken pygments installation.","commonSituations":"Typo in the style name from config/CLI; custom style module not on the path; partial/corrupt pygments package missing a styles submodule; style removed in a newer pygments version.","solutions":["List valid names via get_all_styles() and use an exact one.","For a missing builtin, reinstall pygments cleanly.","For a custom style, ensure its module is importable and on sys.path.","Fix the typo."],"exampleFix":"# before\nstyle = get_style_by_name('monokaii')  # typo\n# after\nstyle = get_style_by_name('monokai')","handlingStrategy":"try-catch","validationCode":"from pygments.styles import get_all_styles\nKNOWN = set(get_all_styles())\nif name not in KNOWN:\n    name = 'default'","typeGuard":null,"tryCatchPattern":"from pygments.util import ClassNotFound\nfrom pygments.styles import get_style_by_name, get_style_by_name\ntry:\n    style = get_style_by_name(name)\nexcept ClassNotFound:\n    style = get_style_by_name('default')","preventionTips":["Validate style names against get_all_styles().","Reinstall pygments if a builtin style module is missing."],"tags":["pygments","style","lookup"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}