Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nbconvert for python 3.9 crashing during the templateexporter.py #2149

Open
ale-franc opened this issue May 16, 2024 · 2 comments
Open

nbconvert for python 3.9 crashing during the templateexporter.py #2149

ale-franc opened this issue May 16, 2024 · 2 comments
Labels
good first issue great for new contributors help wanted

Comments

@ale-franc
Copy link

ale-franc commented May 16, 2024

While trying to convert a minimum jupyter notebook we got the following message.

$ /opt/python/3.9.14/bin/python3.9 -m nbconvert --execute --stdout  --to=html /net/.../fs0/home/ias4ca/Untitled3.ipynb
Traceback (most recent call last):
  File "/opt/python/3.9.14/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/python/3.9.14/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/ias4ca/.local/lib/python3.9/site-packages/nbconvert/__main__.py", line 5, in <module>
    main()
  File "/opt/python/3.9.14/lib/python3.9/site-packages/jupyter_core/application.py", line 283, in launch_instance
    super().launch_instance(argv=argv, **kwargs)
  File "/opt/python/3.9.14/lib/python3.9/site-packages/traitlets/config/application.py", line 1075, in launch_instance
    app.start()
  File "/home/ias4ca/.local/lib/python3.9/site-packages/nbconvert/nbconvertapp.py", line 420, in start
    self.convert_notebooks()
  File "/home/ias4ca/.local/lib/python3.9/site-packages/nbconvert/nbconvertapp.py", line 585, in convert_notebooks
    cls = get_exporter(self.export_format)
  File "/home/ias4ca/.local/lib/python3.9/site-packages/nbconvert/exporters/base.py", line 107, in get_exporter
    if getattr(exporter(config=config), "enabled", True):
  File "/home/ias4ca/.local/lib/python3.9/site-packages/nbconvert/exporters/templateexporter.py", line 350, in __init__
    super().__init__(config=config, **kw)
  File "/home/ias4ca/.local/lib/python3.9/site-packages/nbconvert/exporters/exporter.py", line 123, in __init__
    self._init_preprocessors()
  File "/home/ias4ca/.local/lib/python3.9/site-packages/nbconvert/exporters/templateexporter.py", line 535, in _init_preprocessors
    conf = self._get_conf()
  File "/home/ias4ca/.local/lib/python3.9/site-packages/nbconvert/exporters/templateexporter.py", line 557, in _get_conf
    conf = recursive_update(conf, json.load(f))
  File "/opt/python/3.9.14/lib/python3.9/json/__init__.py", line 293, in load
    return loads(fp.read(),
  File "/opt/python/3.9.14/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/opt/python/3.9.14/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/python/3.9.14/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
$ jupyter --version
Selected Jupyter core packages...
IPython          : 8.18.1
ipykernel        : 6.29.3
ipywidgets       : 8.1.2
jupyter_client   : 7.4.9
jupyter_core     : 5.7.1
jupyter_server   : 2.13.0
jupyterlab       : 3.6.7
nbclient         : 0.9.0
nbconvert        : 7.16.4
nbformat         : 5.9.2
notebook         : 6.5.6
qtconsole        : 5.5.1
traitlets        : 5.14.1

cc: @rstub

@takluyver
Copy link
Member

If you run jupyter --paths and look at the 'data' section you'll see a list of directories. Under each of those directories, look for files like nbconvert/templates/*/conf.json. The traceback looks like one of those files does not contain valid JSON.

It could do with at least a better error message to point to the file that's the issue, and possibly also handling that situation, e.g. issue a warning about the file and carry on like it didn't exist.

@takluyver takluyver added help wanted good first issue great for new contributors labels Aug 8, 2024
@DanielCastroBosch
Copy link

DanielCastroBosch commented Sep 5, 2024

Hi, with jupyter --paths I got:

config:
    /root/.jupyter
    /root/.local/etc/jupyter
    /usr/etc/jupyter
    /usr/local/etc/jupyter
    /etc/jupyter
data:
    /root/.local/share/jupyter
    /usr/local/share/jupyter
    /usr/share/jupyter
runtime:
    /root/.local/share/jupyter/runtime

I checked all of the following conf.json files that were found:

/usr/local/share/jupyter/nbconvert/templates/asciidoc/conf.json
/usr/local/share/jupyter/nbconvert/templates/basic/conf.json
/usr/local/share/jupyter/nbconvert/templates/classic/conf.json
/usr/local/share/jupyter/nbconvert/templates/lab/conf.json
/usr/local/share/jupyter/nbconvert/templates/latex/conf.json
/usr/local/share/jupyter/nbconvert/templates/markdown/conf.json
/usr/local/share/jupyter/nbconvert/templates/python/conf.json
/usr/local/share/jupyter/nbconvert/templates/reveal/conf.json
/usr/local/share/jupyter/nbconvert/templates/rst/conf.json
/usr/local/share/jupyter/nbconvert/templates/script/conf.json
/usr/local/share/jupyter/nbconvert/templates/webpdf/conf.json

They all have valid json:

Displaying content of: /usr/local/share/jupyter/nbconvert/templates/asciidoc/conf.json
{
  "base_template": "base",
  "mimetypes": {
    "text/asciidoc": true
  }
}

Displaying content of: /usr/local/share/jupyter/nbconvert/templates/basic/conf.json
{
  "base_template": "classic",
  "mimetypes": {
    "text/html": true
  }
}

Displaying content of: /usr/local/share/jupyter/nbconvert/templates/classic/conf.json
{
  "base_template": "base",
  "mimetypes": {
    "text/html": true
  },
  "preprocessors": {
    "100-pygments": {
      "type": "nbconvert.preprocessors.CSSHTMLHeaderPreprocessor",
      "enabled": true,
      "style": "default"
    }
  }
}

Displaying content of: /usr/local/share/jupyter/nbconvert/templates/lab/conf.json
{
  "base_template": "base",
  "mimetypes": {
    "text/html": true
  },
  "preprocessors": {
    "100-pygments": {
      "type": "nbconvert.preprocessors.CSSHTMLHeaderPreprocessor",
      "enabled": true
    }
  }
}

Displaying content of: /usr/local/share/jupyter/nbconvert/templates/latex/conf.json
{
  "base_template": "base",
  "mimetypes": {
    "text/latex": true,
    "text/tex": true,
    "application/pdf": true
  }
}

Displaying content of: /usr/local/share/jupyter/nbconvert/templates/markdown/conf.json
{
  "base_template": "base",
  "mimetypes": {
    "text/markdown": true
  }
}

Displaying content of: /usr/local/share/jupyter/nbconvert/templates/python/conf.json
{
  "base_template": "base",
  "mimetypes": {
    "text/x-python": true
  }
}

Displaying content of: /usr/local/share/jupyter/nbconvert/templates/reveal/conf.json
{
  "base_template": "lab",
  "mimetypes": {
    "text/html": true
  },
  "preprocessors": {
    "100-pygments": {
      "type": "nbconvert.preprocessors.CSSHTMLHeaderPreprocessor",
      "enabled": true
    },
    "500-reveal": {
      "type": "nbconvert.exporters.slides._RevealMetadataPreprocessor",
      "enabled": true
    }
  }
}

Displaying content of: /usr/local/share/jupyter/nbconvert/templates/rst/conf.json
{
  "base_template": "base",
  "mimetypes": {
    "text/restructuredtext": true
  }
}

Displaying content of: /usr/local/share/jupyter/nbconvert/templates/script/conf.json
{
  "base_template": "base",
  "mimetypes": {
    "text/plain": true
  }
}

Displaying content of: /usr/local/share/jupyter/nbconvert/templates/webpdf/conf.json
{
  "base_template": "lab",
  "mimetypes": {
    "application/pdf": true
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue great for new contributors help wanted
Projects
None yet
Development

No branches or pull requests

3 participants