nbconvert: ArchLinux Package Broken for 6.0: (Error when exporting to HTML: `TemplateNotFound: static/index.css`)
I am trying to export an empty notebook to HTML (jupyter nbconvert --to html empty.ipynb
), but it fails with TemplateNotFound: static/index.css
(full error message below). I tried b7 and master, and the error is still there; a1 and earlier works fine.
(A caveat is that depending on which version I was on before upgrading, I seemed to get inconsistent results, e.g. being on a1 and then updating to b7 sometimes worked, but being on a6 and upgrading to b7 caused the error. So to reproduce, run pip install https://github.com/jupyter/nbconvert/archive/6.0.0a6.zip
and then pip install https://github.com/jupyter/nbconvert/archive/6.0.0b7.zip
. Sometimes it works when upgrading to master, sometimes not. Is there a template file generated that is cleared by some versions maybe?)
Error message
[NbConvertApp] Converting notebook empty.ipynb to html Traceback (most recent call last): File "/home/joel/miniconda3/envs/mds/bin/jupyter-nbconvert", line 8, in <module> sys.exit(main()) File "/home/joel/miniconda3/envs/mds/lib/python3.8/site-packages/jupyter_core/application.py", line 270, in launch_instance return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs) File "/home/joel/miniconda3/envs/mds/lib/python3.8/site-packages/traitlets/config/application.py", line 838, in launch_instance app.start() File "/home/joel/miniconda3/envs/mds/lib/python3.8/site-packages/nbconvert/nbconvertapp.py", line 345, in start self.convert_notebooks() File "/home/joel/miniconda3/envs/mds/lib/python3.8/site-packages/nbconvert/nbconvertapp.py", line 519, in convert_notebooks self.convert_single_notebook(notebook_filename) File "/home/joel/miniconda3/envs/mds/lib/python3.8/site-packages/nbconvert/nbconvertapp.py", line 484, in convert_single_notebook output, resources = self.export_single_notebook(notebook_filename, resources, input_buffer=input_buffer) File "/home/joel/miniconda3/envs/mds/lib/python3.8/site-packages/nbconvert/nbconvertapp.py", line 413, in export_single_notebook output, resources = self.exporter.from_filename(notebook_filename, resources=resources) File "/home/joel/miniconda3/envs/mds/lib/python3.8/site-packages/nbconvert/exporters/exporter.py", line 182, in from_filename return self.from_file(f, resources=resources, **kw) File "/home/joel/miniconda3/envs/mds/lib/python3.8/site-packages/nbconvert/exporters/exporter.py", line 200, in from_file return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw) File "/home/joel/miniconda3/envs/mds/lib/python3.8/site-packages/nbconvert/exporters/html.py", line 122, in from_notebook_node return super().from_notebook_node(nb, resources, **kw) File "/home/joel/miniconda3/envs/mds/lib/python3.8/site-packages/nbconvert/exporters/templateexporter.py", line 377, in from_notebook_node output = self.template.render(nb=nb_copy, resources=resources) File "/home/joel/.local/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render self.environment.handle_exception() File "/home/joel/.local/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception reraise(*rewrite_traceback_stack(source=source)) File "/home/joel/.local/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise raise value.with_traceback(tb) File "/home/joel/miniconda3/envs/mds/share/jupyter/nbconvert/templates/lab/index.html.j2", line 3, in top-level template code {% from 'jupyter_widgets.html.j2' import jupyter_widgets %} File "/home/joel/miniconda3/envs/mds/share/jupyter/nbconvert/templates/lab/base.html.j2", line 169, in top-level template codeFile “/home/joel/miniconda3/envs/mds/share/jupyter/nbconvert/templates/base/display_priority.j2”, line 1, in top-level template code {%- extends ‘base/null.j2’ -%} File “/home/joel/miniconda3/envs/mds/share/jupyter/nbconvert/templates/base/null.j2”, line 23, in top-level template code #} File “/home/joel/miniconda3/envs/mds/share/jupyter/nbconvert/templates/lab/index.html.j2”, line 6, in block “header” <!DOCTYPE html> File “/home/joel/miniconda3/envs/mds/share/jupyter/nbconvert/templates/lab/index.html.j2”, line 28, in block “html_head” {% endblock extra_css %} File “/home/joel/miniconda3/envs/mds/share/jupyter/nbconvert/templates/lab/index.html.j2”, line 29, in block “notebook_css”
File “/home/joel/miniconda3/envs/mds/lib/python3.8/site-packages/nbconvert/exporters/html.py”, line 127, in resources_include_css code = “”“<style type="text/css">\n%s</style>”“” % (env.loader.get_source(env, name)[0]) File “/home/joel/.local/lib/python3.8/site-packages/jinja2/loaders.py”, line 488, in get_source raise TemplateNotFound(template) jinja2.exceptions.TemplateNotFound: static/index.css
Tested on Linux and Windows
# Linux jupyter --version
jupyter core : 4.6.3
jupyter-notebook : 6.1.3
qtconsole : not installed
ipython : 7.18.1
ipykernel : 5.3.4
jupyter client : 6.1.2
jupyter lab : 2.2.6
nbconvert : 6.0.0b7
ipywidgets : not installed
nbformat : 5.0.5
traitlets : 5.0.0
# Windows jupyter --version
$ jupyter --version
jupyter core : 4.6.3
jupyter-notebook : 6.1.3
qtconsole : not installed
ipython : 7.17.0
ipykernel : 5.3.4
jupyter client : 6.1.6
jupyter lab : 2.2.5
nbconvert : 6.0.0b7
ipywidgets : not installed
nbformat : 5.0.7
traitlets : 4.3.3
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 29 (19 by maintainers)
@Ghabry I opened an issue there a few days ago and just pasted the lasted comment from above also https://bugs.archlinux.org/task/69537
I think the pacman package is broken, which would explain the reports on Arch Linux.
Ok yeah that reproduces on my machine – I typically don’t develop in conda and it doesn’t reproduce in a pure venv setting.
Hey, for doing this I just did a similar script as the one suggested by @atsuoishimoto. Just create a file called
notebook-to-html.py
and paste thisThen just do the following in a terminal
python3 notebook-to-html.py /path/to/notebook.ipynb /path/to/html-file.html
and that’s it. I would just suggest doing a alias while this is being fixed; something like:alias nb2html='python3 /path/to/notebook-to-html.py'
Same issue on Manjaro
FYI, I got same error with my regacy utitiliy like this.
This code works with nbconvert 5.6.1, but raises same error with 6.0.6.
Changing Config to
fixes problem in my case.