无法使用nbconvert将jupyter笔记本导出为任何其他格式

问题描述

我在Windows 10上使用Python 3.8.5。我安装了Jupyterlab,它可以正常工作。但是nbconvert没有。当我尝试将笔记本导出为任何格式时,在终端中出现以下错误

[W 16:14:06.733 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20200928161400 (::1) 8.46ms referer=http://localhost:8889/notebooks/tester1/testing_epr_py.ipynb
[I 16:14:07.066 NotebookApp] Kernel started: 1e1cd4f1-55e7-4583-b343-98ed9670e8f9,name: python3
[E 16:14:10.773 NotebookApp] Uncaught exception GET /nbconvert/html/tester1/testing_epr_py.ipynb?download=true (::1)
    HTTPServerRequest(protocol='http',host='localhost:8889',method='GET',uri='/nbconvert/html/tester1/testing_epr_py.ipynb?download=true',version='HTTP/1.1',remote_ip='::1')
    Traceback (most recent call last):
      File "C:\Users\draco.malfoy\AppData\Roaming\Python\python38\site-packages\traitlets\traitlets.py",line 535,in get
        value = obj._trait_values[self.name]
    KeyError: 'template_paths'

During handling of the above exception,another exception occurred:

Traceback (most recent call last):
  File "C:\Users\draco.malfoy\AppData\Roaming\Python\python38\site-packages\tornado\web.py",line 1703,in _execute
    result = await result
  File "C:\Users\draco.malfoy\AppData\Roaming\Python\python38\site-packages\tornado\gen.py",line 209,in wrapper
    yielded = next(result)
  File "C:\Users\draco.malfoy\AppData\Roaming\Python\python38\site-packages\notebook\nbconvert\handlers.py",line 93,in get
    exporter = get_exporter(format,config=self.config,log=self.log)
  File "C:\Users\draco.malfoy\AppData\Roaming\Python\python38\site-packages\notebook\nbconvert\handlers.py",line 67,in get_exporter
    Exporter = get_exporter(format)
  File "C:\Users\draco.malfoy\AppData\Roaming\Python\python38\site-packages\nbconvert\exporters\base.py",line 102,in get_exporter
    if getattr(exporter(config=config),'enabled',True):
  File "C:\Users\draco.malfoy\AppData\Roaming\Python\python38\site-packages\nbconvert\exporters\templateexporter.py",line 328,in __init__
    super().__init__(config=config,**kw)
  File "C:\Users\draco.malfoy\AppData\Roaming\Python\python38\site-packages\nbconvert\exporters\exporter.py",line 114,in __init__
    self._init_preprocessors()
  File "C:\Users\draco.malfoy\AppData\Roaming\Python\python38\site-packages\nbconvert\exporters\templateexporter.py",line 494,in _init_preprocessors
    conf = self._get_conf()
  File "C:\Users\draco.malfoy\AppData\Roaming\Python\python38\site-packages\nbconvert\exporters\templateexporter.py",line 510,in _get_conf
    for path in map(Path,self.template_paths):
  File "C:\Users\draco.malfoy\AppData\Roaming\Python\python38\site-packages\traitlets\traitlets.py",line 575,in __get__
    return self.get(obj,cls)
  File "C:\Users\draco.malfoy\AppData\Roaming\Python\python38\site-packages\traitlets\traitlets.py",line 538,in get
    default = obj.trait_defaults(self.name)
  File "C:\Users\draco.malfoy\AppData\Roaming\Python\python38\site-packages\traitlets\traitlets.py",line 1577,in trait_defaults
    return self._get_trait_default_generator(names[0])(self)
  File "C:\Users\draco.malfoy\AppData\Roaming\Python\python38\site-packages\traitlets\traitlets.py",line 975,in __call__
    return self.func(*args,**kwargs)
  File "C:\Users\draco.malfoy\AppData\Roaming\Python\python38\site-packages\nbconvert\exporters\templateexporter.py",line 521,in _template_paths
    template_names = self.get_template_names()
  File "C:\Users\draco.malfoy\AppData\Roaming\Python\python38\site-packages\nbconvert\exporters\templateexporter.py",line 582,in get_template_names
    raise ValueError('No template sub-directory with name %r found in the following paths:\n\t%s' % (base_template,paths))
ValueError: No template sub-directory with name 'lab' found in the following paths:
    C:\Users\draco.malfoy\AppData\Roaming\jupyter
    C:\Program Files\python38\share\jupyter
    C:\ProgramData\jupyter

我也尝试通过命令行使用nbconvert,但是遇到了同样的错误nbconvert版本是6.0.6。任何帮助将不胜感激。

解决方法

从“C:\Users\{username}\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\share\jupyter”复制文件 到“C:\ProgramData\jupyter”帮助我解决了这个问题,请注意,如果你想转换笔记本,你必须在 Windows 上安装 Pandoc 和 MiKTex。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...