解决Jupyter notebook报错:AssertionError: wrong color format ‘var(--jp-mirror-editor-variable-color)‘

今天使用jupyter notebook时出错:

500: Internal Server Error

错误现象

查看日志:

AssertionError: wrong color format 'var(--jp-mirror-editor-variable-color)'

[E 13:56:50.149 NotebookApp] Uncaught exception GET /notebooks/MongoDB-Soul.ipynb (127.0.0.1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/notebooks/MongoDB-Soul.ipynb', version='HTTP/1.1', remote_ip='127.0.0.1')
    Traceback (most recent call last):
      File "D:\ProgramData\Anaconda3\lib\site-packages\tornado\web.py", line 1703, in _execute
        result = await result
      File "D:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 748, in run
        yielded = self.gen.send(value)
      File "D:\ProgramData\Anaconda3\lib\site-packages\notebook\notebook\handlers.py", line 95, in get
        self.write(self.render_template('notebook.html',
      File "D:\ProgramData\Anaconda3\lib\site-packages\notebook\base\handlers.py", line 512, in render_template
        return template.render(**ns)
      File "D:\ProgramData\Anaconda3\lib\site-packages\jinja2\environment.py", line 1090, in render
        self.environment.handle_exception()
      File "D:\ProgramData\Anaconda3\lib\site-packages\jinja2\environment.py", line 832, in handle_exception
        reraise(*rewrite_traceback_stack(source=source))
      File "D:\ProgramData\Anaconda3\lib\site-packages\jinja2\_compat.py", line 28, in reraise
        raise value.with_traceback(tb)
      File "D:\ProgramData\Anaconda3\lib\site-packages\notebook\templates\notebook.html", line 1, in top-level template code
        {% extends "page.html" %}
      File "D:\ProgramData\Anaconda3\lib\site-packages\notebook\templates\page.html", line 154, in top-level template code
        {% block header %}
      File "D:\ProgramData\Anaconda3\lib\site-packages\notebook\templates\notebook.html", line 115, in block "header"
        {% for exporter in get_frontend_exporters() %}
      File "D:\ProgramData\Anaconda3\lib\site-packages\notebook\notebook\handlers.py", line 40, in get_frontend_exporters
        for name in get_export_names():
      File "D:\ProgramData\Anaconda3\lib\site-packages\nbconvert\exporters\base.py", line 141, in get_export_names
        e = get_exporter(exporter_name)(config=config)
      File "D:\ProgramData\Anaconda3\lib\site-packages\nbconvert\exporters\base.py", line 101, in get_exporter
        exporter = entrypoints.get_single('nbconvert.exporters', name).load()
      File "D:\ProgramData\Anaconda3\lib\site-packages\entrypoints.py", line 82, in load
        mod = import_module(self.module_name)
      File "D:\ProgramData\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
      File "<frozen importlib._bootstrap>", line 991, in _find_and_load
      File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
      File "<frozen importlib._bootstrap>", line 991, in _find_and_load
      File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 783, in exec_module
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "D:\ProgramData\Anaconda3\lib\site-packages\nbconvert\__init__.py", line 6, in <module>
        from . import preprocessors
      File "D:\ProgramData\Anaconda3\lib\site-packages\nbconvert\preprocessors\__init__.py", line 7, in <module>
        from .csshtmlheader import CSSHTMLHeaderPreprocessor
      File "D:\ProgramData\Anaconda3\lib\site-packages\nbconvert\preprocessors\csshtmlheader.py", line 14, in <module>
        from jupyterlab_pygments import JupyterStyle
      File "D:\ProgramData\Anaconda3\lib\site-packages\jupyterlab_pygments\__init__.py", line 4, in <module>
        from .style import JupyterStyle
      File "D:\ProgramData\Anaconda3\lib\site-packages\jupyterlab_pygments\style.py", line 10, in <module>
        class JupyterStyle(Style):
      File "D:\ProgramData\Anaconda3\lib\site-packages\pygments\style.py", line 101, in __new__
        elif styledef == 'nobold':
      File "D:\ProgramData\Anaconda3\lib\site-packages\pygments\style.py", line 58, in colorformat
        class StyleMeta(type):
    AssertionError: wrong color format 'var(--jp-mirror-editor-variable-color)'
[E 13:56:50.158 NotebookApp] {
      "Host": "localhost:8888",
      "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:95.0) Gecko/20100101 Firefox/95.0",
      "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
      "Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
      "Accept-Encoding": "gzip, deflate",
      "Referer": "http://localhost:8888/tree",
      "Connection": "keep-alive",
      "Cookie": "username-localhost-8889=\"2|1:0|10:1637236743|23:username-localhost-8889|44:OTBlZTk3MjlmODIzNGExYWFhYzQ3NTZiMmI2MTUwZTM=|450fdc6992b203dce4879f1bb2579100393b21469e186b86d457fd4fb7a00cae\"; username-localhost-8888=\"2|1:0|10:1639806888|23:username-localhost-8888|44:N2E2ODQ2OTIzZDBkNGNiMDkwYjgwMGI1MmUyYjMzNDQ=|673adeb337c2039f53c098181781aff7f6cf206d6f765b3afbe609c2222f4150\"; _xsrf=2|4adf7ea7|20b2bab02e528e4a53ea58a131398aff|1639806684",
      "Upgrade-Insecure-Requests": "1",
      "Sec-Fetch-Dest": "document",
      "Sec-Fetch-Mode": "navigate",
      "Sec-Fetch-Site": "same-origin",
      "Sec-Fetch-User": "?1",
      "Cache-Control": "max-age=0"
    }
[E 13:56:50.158 NotebookApp] 500 GET /notebooks/MongoDB-Soul.ipynb (127.0.0.1) 176.90ms referer=http://localhost:8888/tree
[E 13:56:51.252 NotebookApp] Uncaught exception GET /notebooks/MongoDB-Soul.ipynb (127.0.0.1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/notebooks/MongoDB-Soul.ipynb', version='HTTP/1.1', remote_ip='127.0.0.1')
    Traceback (most recent call last):
      File "D:\ProgramData\Anaconda3\lib\site-packages\tornado\web.py", line 1703, in _execute
        result = await result
      File "D:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 748, in run
        yielded = self.gen.send(value)
      File "D:\ProgramData\Anaconda3\lib\site-packages\notebook\notebook\handlers.py", line 95, in get
        self.write(self.render_template('notebook.html',
      File "D:\ProgramData\Anaconda3\lib\site-packages\notebook\base\handlers.py", line 512, in render_template
        return template.render(**ns)
      File "D:\ProgramData\Anaconda3\lib\site-packages\jinja2\environment.py", line 1090, in render
        self.environment.handle_exception()
      File "D:\ProgramData\Anaconda3\lib\site-packages\jinja2\environment.py", line 832, in handle_exception
        reraise(*rewrite_traceback_stack(source=source))
      File "D:\ProgramData\Anaconda3\lib\site-packages\jinja2\_compat.py", line 28, in reraise
        raise value.with_traceback(tb)
      File "D:\ProgramData\Anaconda3\lib\site-packages\notebook\templates\notebook.html", line 1, in top-level template code
        {% extends "page.html" %}
      File "D:\ProgramData\Anaconda3\lib\site-packages\notebook\templates\page.html", line 154, in top-level template code
        {% block header %}
      File "D:\ProgramData\Anaconda3\lib\site-packages\notebook\templates\notebook.html", line 115, in block "header"
        {% for exporter in get_frontend_exporters() %}
      File "D:\ProgramData\Anaconda3\lib\site-packages\notebook\notebook\handlers.py", line 40, in get_frontend_exporters
        for name in get_export_names():
      File "D:\ProgramData\Anaconda3\lib\site-packages\nbconvert\exporters\base.py", line 141, in get_export_names
        e = get_exporter(exporter_name)(config=config)
      File "D:\ProgramData\Anaconda3\lib\site-packages\nbconvert\exporters\base.py", line 102, in get_exporter
        if getattr(exporter(config=config), 'enabled', True):
      File "D:\ProgramData\Anaconda3\lib\site-packages\nbconvert\exporters\templateexporter.py", line 325, in __init__
        self.observe(self._invalidate_environment_cache,
      File "D:\ProgramData\Anaconda3\lib\site-packages\nbconvert\exporters\exporter.py", line 114, in __init__
      File "D:\ProgramData\Anaconda3\lib\site-packages\nbconvert\exporters\templateexporter.py", line 490, in _init_preprocessors
        preprocessors = conf.get('preprocessors', {})
      File "D:\ProgramData\Anaconda3\lib\site-packages\nbconvert\exporters\exporter.py", line 262, in _init_preprocessors
        for preprocessor in self.default_preprocessors:
      File "D:\ProgramData\Anaconda3\lib\site-packages\nbconvert\exporters\exporter.py", line 227, in register_preprocessor
        # this register_preprocessor method
      File "D:\ProgramData\Anaconda3\lib\site-packages\traitlets\utils\importstring.py", line 30, in import_item
        module = __import__(package, fromlist=[obj])
      File "D:\ProgramData\Anaconda3\lib\site-packages\nbconvert\__init__.py", line 6, in <module>
        from . import preprocessors
      File "D:\ProgramData\Anaconda3\lib\site-packages\nbconvert\preprocessors\__init__.py", line 7, in <module>
        from .csshtmlheader import CSSHTMLHeaderPreprocessor
      File "D:\ProgramData\Anaconda3\lib\site-packages\nbconvert\preprocessors\csshtmlheader.py", line 14, in <module>
        from jupyterlab_pygments import JupyterStyle
      File "D:\ProgramData\Anaconda3\lib\site-packages\jupyterlab_pygments\__init__.py", line 4, in <module>
        from .style import JupyterStyle
      File "D:\ProgramData\Anaconda3\lib\site-packages\jupyterlab_pygments\style.py", line 10, in <module>
        class JupyterStyle(Style):
      File "D:\ProgramData\Anaconda3\lib\site-packages\pygments\style.py", line 101, in __new__
        elif styledef == 'nobold':
      File "D:\ProgramData\Anaconda3\lib\site-packages\pygments\style.py", line 58, in colorformat
        class StyleMeta(type):
    AssertionError: wrong color format 'var(--jp-mirror-editor-variable-color)'
[E 13:56:51.259 NotebookApp] {
      "Host": "localhost:8888",
      "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:95.0) Gecko/20100101 Firefox/95.0",
      "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
      "Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
      "Accept-Encoding": "gzip, deflate",
      "Referer": "http://localhost:8888/tree",
      "Connection": "keep-alive",
      "Cookie": "username-localhost-8889=\"2|1:0|10:1637236743|23:username-localhost-8889|44:OTBlZTk3MjlmODIzNGExYWFhYzQ3NTZiMmI2MTUwZTM=|450fdc6992b203dce4879f1bb2579100393b21469e186b86d457fd4fb7a00cae\"; username-localhost-8888=\"2|1:0|10:1639806888|23:username-localhost-8888|44:N2E2ODQ2OTIzZDBkNGNiMDkwYjgwMGI1MmUyYjMzNDQ=|673adeb337c2039f53c098181781aff7f6cf206d6f765b3afbe609c2222f4150\"; _xsrf=2|4adf7ea7|20b2bab02e528e4a53ea58a131398aff|1639806684",
      "Upgrade-Insecure-Requests": "1",
      "Sec-Fetch-Dest": "document",
      "Sec-Fetch-Mode": "navigate",
      "Sec-Fetch-Site": "same-origin",
      "Sec-Fetch-User": "?1",
      "Cache-Control": "max-age=0"
    }
[E 13:56:51.259 NotebookApp] 500 GET /notebooks/MongoDB-Soul.ipynb (127.0.0.1) 127.86ms referer=http://localhost:8888/tree

原因

这是由 nbconvert 库的不兼容版本引起的。 如果没有将 nbconvert 固定到正确的版本,则可能会意外通过 PyPI 安装不兼容的版本。

解决方案

手动安装 nbconvert 版本 6.0.0rc0。 这将重写可能已安装的库的任何不正确版本。

pip install nbconvert==6.0.0rc0

重启jupyter notebook即可正常运行

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值