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)'


这是由于库的版本不兼容引起的 nbconvertThis 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.0 rc0。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.0rc0在 "" 字段中输入。Enter nbconvert==6.0.0rc0 in the Package field.
  7. 单击“安装” 。Click Install.