Python 命令失败,提示 AssertionError: wrong color formatPython command fails with AssertionError: wrong color format


运行 Python 笔记本,它会失败并显示 AssertionError: wrong color format 消息。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)'


这是由 nbconvert 库的不兼容版本引起的。This is caused by an incompatible version of the nbconvert library. 如果没有将 nbconvert 固定到正确的版本,则可能会意外通过 PyPI 安装不兼容的版本。If you do not have nbconvert pinned to the correct version, it is possible to accidentally install an incompatible version via PyPI.


在群集上手动安装 nbconvert 版本 6.0.0rc0。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. 在“库源”按钮列表中,选择“PyPi”。In the Library Source button list, select PyPi.
  6. 在“包”字段中输入 nbconvert==6.0.0rc0Enter nbconvert==6.0.0rc0 in the Package field.
  7. 单击“安装”。Click Install.