pygments-styles
raw JSON → 0.3.0 verified Fri May 01 auth: no python
A curated collection of Pygments styles based on VS Code themes. Current version 0.3.0, released on an as-needed basis (latest update: 2026-04-02). Requires Python >=3.9.
pip install pygments-styles Common errors
error ModuleNotFoundError: No module named 'pygments_styles' ↓
cause The package is not installed or installed in a different environment.
fix
Run: pip install pygments-styles
error ValueError: Style 'github-dark' is not a known style ↓
cause Style name is misspelled, wrong case, or the style wasn't loaded. Ensure you use an exact name from the list.
fix
Run: from pygments_styles import list_styles; print(list_styles()) to see available names.
error ImportError: cannot import name 'PygmentsStylesRegistry' from 'pygments_styles' ↓
cause Wrong import path; the registry is exposed at package root, not in a submodule.
fix
Use: from pygments_styles import PygmentsStylesRegistry
Warnings
gotcha Style names are case-sensitive and must match exactly as documented (e.g., 'github-dark', 'github-light'). Mismatched names raise a ValueError. ↓
fix Use get_style_by_name() to retrieve a style; it raises clear errors on unknown names.
gotcha The package only provides styles, not lexers or formatters. You must have Pygments installed separately. ↓
fix Install Pygments: pip install Pygments
gotcha Some styles (e.g., 'ayu-mirage') include custom token colors that may not be fully supported by older Pygments versions. Ensure Pygments >=2.7 for best compatibility. ↓
fix Upgrade Pygments: pip install Pygments>=2.7
Imports
- PygmentsStylesRegistry wrong
from pygments_styles.registry import PygmentsStylesRegistrycorrectfrom pygments_styles import PygmentsStylesRegistry - list_styles wrong
from pygments_styles.styles import list_stylescorrectfrom pygments_styles import list_styles - get_style_by_name wrong
from pygments_styles.utils import get_style_by_namecorrectfrom pygments_styles import get_style_by_name
Quickstart
from pygments import highlight
from pygments.lexers import PythonLexer
from pygments.formatters import HtmlFormatter
from pygments_styles import get_style_by_name
code = 'print("Hello, World!")'
style = get_style_by_name('github-dark')
formatter = HtmlFormatter(style=style)
result = highlight(code, PythonLexer(), formatter)
print(result)