{"id":527,"library":"jupyterlab-pygments","title":"JupyterLab Pygments Theme","description":"This package provides a syntax highlighting theme for Pygments, designed to leverage JupyterLab's CSS variables. It aims to integrate Pygments-generated HTML code blocks seamlessly with the visual styling of JupyterLab themes. The current version is 0.3.0, released on November 23, 2023, and it is actively maintained by the Jupyter Development Team.","status":"active","version":"0.3.0","language":"python","source_language":"en","source_url":"https://github.com/jupyterlab/jupyterlab_pygments.git","tags":["jupyter","jupyterlab","pygments","theme","syntax-highlighting","frontend"],"install":[{"cmd":"pip install jupyterlab-pygments","lang":"bash","label":"Install via pip"},{"cmd":"conda install -c conda-forge jupyterlab_pygments","lang":"bash","label":"Install via Conda"}],"dependencies":[{"reason":"Core dependency for syntax highlighting; requires version >=2.4.1.","package":"pygments"}],"imports":[{"note":"While you can import the package, its primary function is to register a Pygments style named 'jupyterlab'. You typically use this style by name with Pygments' formatters, rather than directly importing symbols from the package itself for style application.","symbol":"jupyterlab_pygments","correct":"import jupyterlab_pygments"},{"note":"The 'jupyterlab' style is automatically registered by Pygments when the package is installed. Access it by name when creating a Pygments formatter.","symbol":"style='jupyterlab'","correct":"from pygments.formatters import HtmlFormatter\nformatter = HtmlFormatter(style='jupyterlab')"}],"quickstart":{"code":"from pygments import highlight\nfrom pygments.lexers import PythonLexer\nfrom pygments.formatters import HtmlFormatter\nfrom IPython.display import HTML, display\n\n# Example Python code to highlight\ncode_to_highlight = \"\"\"\ndef greet(name):\n    print(f\"Hello, {name}!\")\n\ngreet(\"World\")\n\"\"\"\n\n# Create an HTML formatter using the 'jupyterlab' style\n# The style 'jupyterlab' is made available by the jupyterlab-pygments package\nformatter = HtmlFormatter(style='jupyterlab', full=True, cssclass='highlight-jupyterlab')\n\n# Generate the HTML output with highlighting\nhighlighted_html = highlight(code_to_highlight, PythonLexer(), formatter)\n\n# To display in a Jupyter environment, use IPython.display\n# For standalone use, you would typically write highlighted_html to a file.\n# The 'full=True' option includes the <style> tags, making it self-contained.\ndisplay(HTML(highlighted_html))","lang":"python","description":"This quickstart demonstrates how to use the `jupyterlab` Pygments style to highlight Python code and display it within a Jupyter environment. The `HtmlFormatter` is configured with `style='jupyterlab'` to apply the theme, and `full=True` to embed the necessary CSS."},"warnings":[{"fix":"Be aware of these inherent limitations of Pygments styling when expecting an exact match to CodeMirror's rendering.","message":"Pygments-generated HTML and CSS classes from this theme are not as granular as JupyterLab's CodeMirror editor. This means some visual nuances, like differentiating properties from general names or how dots in `foo.bar` are styled, cannot be perfectly replicated.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure that the generated HTML and CSS are properly scoped (e.g., by using a unique `cssclass` for the formatter and styling it appropriately) to minimize conflicts. Consider generating `full=True` output that includes the `<style>` tags for isolated styling.","message":"When directly embedding Pygments-generated HTML and CSS (especially with `HtmlFormatter`) into Jupyter Notebook/Lab cell outputs, the CSS can sometimes conflict with the global Jupyter theme, potentially affecting the readability of other output elements or applying unintended styles.","severity":"gotcha","affected_versions":"All versions"},{"fix":"This is an ongoing issue being addressed by the JupyterLab team, with work moving towards a separate `jupyterlab-builder` package. Packagers should monitor the `jupyterlab/jupyterlab-builder` repository for updates and potential solutions.","message":"There have been reported issues with recursive build-time dependencies (e.g., `jupyterlab-pygments`, `jupyterlab`, `nbconvert`) leading to bootstrapping problems during packaging, especially when upgrading Python versions (e.g., 3.8 to 3.9). This can make it difficult for packagers to build and install these components.","severity":"breaking","affected_versions":"All versions, particularly affecting package maintainers"},{"fix":"Upgrade your JupyterLab installation to version 4.x or later. This theme should remain compatible across JupyterLab versions, but leveraging a current JupyterLab host is recommended.","message":"While `jupyterlab-pygments` is a theme, its primary environment, JupyterLab 3, reached its end-of-maintenance on May 15, 2024, with critical fixes only until December 31, 2024. Users are strongly encouraged to upgrade to JupyterLab 4 for continued support and new features.","severity":"deprecated","affected_versions":"<4.0.0 (for host JupyterLab version)"},{"fix":"Ensure `pygments` is installed in your Python environment using `pip install pygments` or by including it in your project's `requirements.txt`.","message":"The `pygments` package is a core dependency for syntax highlighting and must be explicitly installed in the environment for scripts or applications that use it. A `ModuleNotFoundError` indicates that the package is missing.","severity":"breaking","affected_versions":"All versions"},{"fix":"Ensure that the `pygments` package is installed in your Python environment. This can typically be resolved by running `pip install pygments` or by including it in your project's dependency management file (e.g., `requirements.txt`).","message":"The `pygments` library, which is a fundamental dependency for `jupyterlab-pygments` and Pygments-related operations, is not found in the Python environment, leading to a `ModuleNotFoundError`.","severity":"breaking","affected_versions":"All versions (this is an environment setup issue, not specific to library versions)"}],"env_vars":null,"last_verified":"2026-05-12T14:40:28.014Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"Ensure `jupyterlab-pygments` is installed, then navigate to JupyterLab's Settings -> Theme and select a JupyterLab theme that utilizes the Pygments CSS variables.","cause":"The JupyterLab Pygments theme might not be correctly activated or is being overridden by other JupyterLab theme settings.","error":"jupyterlab-pygments theme not applying"},{"fix":"Install `jupyterlab` (which includes `jupyterlab-pygments` as a dependency) using pre-built wheels with `pip install jupyterlab`. If managing custom environments, ensure build-time dependencies are resolved without circular references.","cause":"This error typically occurs due to recursive or circular dependencies during `pip` installation, especially when attempting to build packages from source or in complex packaging environments.","error":"LookupError: ... jupyterlab_pygments-0.2.2.tar.gz ... is already being built: jupyterlab-pygments"},{"fix":"Install the package using pip: `pip install jupyterlab-pygments`.","cause":"The `jupyterlab-pygments` package is either not installed in the current Python environment or is not accessible in the Python path.","error":"ModuleNotFoundError: No module named 'jupyterlab_pygments'"},{"fix":"When using `HtmlFormatter` from Pygments, provide a unique `cssclass` argument, which ensures the generated CSS is scoped and less likely to interfere with global JupyterLab styles. Alternatively, inject CSS with higher specificity to override unintended styling.","cause":"Pygments-generated HTML and CSS classes may not be sufficiently granular or prefixed, leading to styling conflicts where Pygments' styles unintentionally affect other elements in the JupyterLab notebook.","error":"Applying the Pygment's CSS to a notebook changes stuff outside pygments"}],"ecosystem":"pypi","meta_description":null,"install_score":0,"install_tag":"stale","quickstart_score":0,"quickstart_tag":"stale","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}}