Unable to export jupyter notebook to any other format using nbconvert

2.9k Views Asked by At

I am using Python 3.8.5 on Windows 10. I installed Jupyterlab and it works correctly. However nbconvert does not. When I try to export notebook to any format, I get the following error in the terminal:

[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

I also tried to use nbconvert through command line but got the same error. nbconvert version is 6.0.6. Any help is greatly appreciated.

1

There are 1 best solutions below

0
On

Copying files from "C:\Users\{username}\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\share\jupyter" to "C:\ProgramData\jupyter" helped me solve this issue, kindly note that you will have to install Pandoc and MiKTex on Windows if you want to convert notebooks.