Export to html fails with jinja template problem
See original GitHub issueNightly build is failing with this error:
CSSHTMLHeaderPreprocessor [NbConvertApp] Attempting to load template index.html.j2 [NbConvertApp] template_paths: /opt/hostedtoolcache/Python/3.9.10/x64/share/jupyter/nbconvert/templates/lab:/opt/hostedtoolcache/Python/3.9.10/x64/share/jupyter/nbconvert/templates/base:/home/runner/.local/share/jupyter:/home/runner/.local/share/jupyter/nbconvert/templates:/home/runner/.local/share/jupyter/nbconvert/templates/compatibility:/opt/hostedtoolcache/Python/3.9.10/x64/share/jupyter:/opt/hostedtoolcache/Python/3.9.10/x64/share/jupyter/nbconvert/templates:/opt/hostedtoolcache/Python/3.9.10/x64/share/jupyter/nbconvert/templates/compatibility:/usr/local/share/jupyter:/usr/local/share/jupyter/nbconvert/templates:/usr/local/share/jupyter/nbconvert/templates/compatibility:/usr/share/jupyter:/usr/share/jupyter/nbconvert/templates:/usr/share/jupyter/nbconvert/templates/compatibility:/opt/hostedtoolcache/Python/3.9.10/x64/share/jupyter/nbconvert/templates Traceback (most recent call last): File "/opt/hostedtoolcache/Python/3.9.10/x64/bin/jupyter-nbconvert", line 8, in <module> sys.exit(main()) File "/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/site-packages/jupyter_core/application.py", line 264, in launch_instance return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs) File "/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/site-packages/traitlets/config/application.py", line 846, in launch_instance app.start() File "/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/site-packages/nbconvert/nbconvertapp.py", line 369, in start self.convert_notebooks() File "/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/site-packages/nbconvert/nbconvertapp.py", line 541, in convert_notebooks self.convert_single_notebook(notebook_filename) File "/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/site-packages/nbconvert/nbconvertapp.py", line 506, in convert_single_notebook output, resources = self.export_single_notebook(notebook_filename, resources, input_buffer=input_buffer) File "/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/site-packages/nbconvert/nbconvertapp.py", line 435, in export_single_notebook output, resources = self.exporter.from_filename(notebook_filename, resources=resources) File "/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/site-packages/nbconvert/exporters/exporter.py", line 190, in from_filename return self.from_file(f, resources=resources, **kw) File "/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/site-packages/nbconvert/exporters/exporter.py", line 208, in from_file return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw) File "/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/site-packages/nbconvert/exporters/html.py", line 210, in from_notebook_node return super().from_notebook_node(nb, resources, **kw) File "/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/site-packages/nbconvert/exporters/templateexporter.py", line 392, in from_notebook_node output = self.template.render(nb=nb_copy, resources=resources) File "/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/site-packages/jinja2/environment.py", line 1291, in render self.environment.handle_exception() File "/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/site-packages/jinja2/environment.py", line 926, in handle_exception raise rewrite_traceback_stack(source=source) File "/opt/hostedtoolcache/Python/3.9.10/x64/share/jupyter/nbconvert/templates/lab/index.html.j2", line 3, in top-level template code {% from 'jupyter_widgets.html.j2' import jupyter_widgets %} File "/opt/hostedtoolcache/Python/3.9.10/x64/share/jupyter/nbconvert/templates/lab/base.html.j2", line 260, in top-level template code {% set div_id = uuid4() %} File "/opt/hostedtoolcache/Python/3.9.10/x64/share/jupyter/nbconvert/templates/base/display_priority.j2", line 1, in top-level template code {%- extends 'base/null.j2' -%} File "/opt/hostedtoolcache/Python/3.9.10/x64/share/jupyter/nbconvert/templates/base/null.j2", line 24, in top-level template code {%- block header -%} File "/opt/hostedtoolcache/Python/3.9.10/x64/share/jupyter/nbconvert/templates/lab/index.html.j2", line 9, in block 'header' {%- block html_head -%} File "/opt/hostedtoolcache/Python/3.9.10/x64/share/jupyter/nbconvert/templates/lab/index.html.j2", line 36, in block 'html_head' {% block notebook_css %} File "/opt/hostedtoolcache/Python/3.9.10/x64/share/jupyter/nbconvert/templates/lab/index.html.j2", line 37, in block 'notebook_css' {{ resources.include_css("static/index.css") }} File "/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/site-packages/nbconvert/exporters/html.py", line 216, in resources_include_css return jinja2.Markup(code) AttributeError: module 'jinja2' has no attribute 'Markup'
I can’t seem to repro locally. Maybe only on linux does it fail.
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Jinja2 not loading template - Stack Overflow
I was following this tutorial and although I seem to doing everything correctly it is not able to find the template. jinja ├──...
Read more >API — Jinja Documentation (3.1.x)
To load a template from this environment, call the get_template() method, which returns the loaded Template . template = env.get_template("mytemplate.html").
Read more >BashOperator — Airflow Documentation
t2 = BashOperator( task_id="bash_example", # This fails with 'Jinja template not found' error # bash_command="/home/batcher/test.sh", # This works (has a ...
Read more >Primer on Jinja Templating - Real Python
If you don't provide context for the variables in a template, they don't throw an error. But they render an empty string, which...
Read more >Jinja Errors - Bloomreach Documentation
The error occurs when jinja is too complex. For example, when there are too many calls in catalogs or recommendations, too long computing...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Workaround, downgrade jinja2 to 3.0.3
Ran into this problem today in vs code - Python 3.9. The work-around suggested by rchiodo above worked perfectly for me.