Python command fails with AssertionError: wrong color format

Resolve a wrong color format AssertionError caused by nbconvert when a Python command fails.

Written by John.Lourdu

Last published at: May 16th, 2022


You run a Python notebook and it fails with an AssertionError: wrong color format message.

An example stack trace:

  File "/local_disk0/tmp/1599775649524-0/", line 39, in <module>
    from IPython.nbconvert.filters.ansi import ansi2html
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 963, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 902, in _find_spec
  File "<frozen importlib._bootstrap>", line 876, in _find_spec_legacy
  File "/databricks/python/lib/python3.7/site-packages/IPython/utils/", line 36, in find_module
    mod = import_item(mirror_name)
  File "/databricks/python/lib/python3.7/site-packages/IPython/utils/", line 31, in import_item
    module = __import__(package, fromlist=[obj])
  File "/databricks/python/lib/python3.7/site-packages/nbconvert/", line 4, in <module>
    from .exporters import *
  File "/databricks/python/lib/python3.7/site-packages/nbconvert/exporters/", line 4, in <module>
    from .slides import SlidesExporter
  File "/databricks/python/lib/python3.7/site-packages/nbconvert/exporters/", line 12, in <module>
    from ..preprocessors.base import Preprocessor
  File "/databricks/python/lib/python3.7/site-packages/nbconvert/preprocessors/", line 7, in <module>
    from .csshtmlheader import CSSHTMLHeaderPreprocessor
  File "/databricks/python/lib/python3.7/site-packages/nbconvert/preprocessors/", line 14, in <module>
    from jupyterlab_pygments import JupyterStyle
  File "/databricks/python/lib/python3.7/site-packages/jupyterlab_pygments/", line 4, in <module>
    from .style import JupyterStyle
  File "/databricks/python/lib/python3.7/site-packages/jupyterlab_pygments/", line 10, in <module>
    class JupyterStyle(Style):
  File "/databricks/python/lib/python3.7/site-packages/pygments/", line 101, in __new__
    ndef[0] = colorformat(styledef)
  File "/databricks/python/lib/python3.7/site-packages/pygments/", line 58, in colorformat
    assert False, "wrong color format %r" % text
AssertionError: wrong color format 'var(--jp-mirror-editor-variable-color)'


This is caused by an incompatible version of the nbconvert library. If you do not have nbconvert pinned to the correct version, it is possible to accidentally install an incompatible version via PyPI.


Manually install nbconvert version 6.0.0rc0 on the cluster. This overrides any incorrect version of the library that may have been installed.

  1. Click the clusters icon in the sidebar.
  2. Click the cluster name.
  3. Click the Libraries tab.
  4. Click Install New.
  5. In the Library Source button list, select PyPi.
  6. Enter nbconvert==6.0.0rc0 in the Package field.
  7. Click Install.
Was this article helpful?