jupyter-book icon indicating copy to clipboard operation
jupyter-book copied to clipboard

Theme error in sample project created with jb create

Open epogrebnyak opened this issue 3 years ago • 2 comments

Describe the bug

context

I'm running jupyter-book build . --builder pdfhtml on a fresh sample created by jb create:

jb create sample-book
cd sample-book
jupyter-book build . --builder pdfhtml

I encountered _config.toml needs language to be specified for sphinx (maybe add this to create result?):

sphinx:
  config:
    language: en

I expect puppeteer to build a PDF but something is still missing, here is the trace:

root@LAPTOP-E0HT1CM9:/mnt/q/chaos-mirror/sample-book# jupyter-book build . --builder pdfhtml
Running Jupyter-Book v0.13.0
Source Folder: /mnt/q/chaos-mirror/sample-book
Config Path: /mnt/q/chaos-mirror/sample-book/_config.yml
Output Path: /mnt/q/chaos-mirror/sample-book/_build/html
Running Sphinx v5.1.1
making output directory... done
[etoc] Changing master_doc to 'intro'
checking bibtex cache... out of date
parsing bibtex file /mnt/q/chaos-mirror/sample-book/references.bib... parsed 5 entries
myst v0.18.0: MdParserConfig(commonmark_only=False, gfm_only=False, enable_extensions=['colon_fence', 'dollarmath', 'linkify', 'substitution', 'tasklist'], disable_syntax=[], all_links_external=False, url_schemes=['mailto', 'http', 'https'], ref_domains=None, highlight_code_blocks=True, number_code_blocks=[], title_to_header=False, heading_anchors=None, heading_slug_func=None, footnote_transition=True, words_per_minute=200, sub_delimiters=('{', '}'), linkify_fuzzy_links=True, dmath_allow_labels=True, dmath_allow_space=True, dmath_allow_digits=True, dmath_double_inline=False, update_mathjax=True, mathjax_classes='tex2jax_process|mathjax_process|math|output_area')
WARNING: 'jupyter_execute_notebooks' is deprecated for 'nb_execution_mode' [mystnb.config]
WARNING: 'jupyter_cache' is deprecated for 'nb_execution_cache_path' [mystnb.config]
WARNING: 'execution_excludepatterns' is deprecated for 'nb_execution_excludepatterns' [mystnb.config]
WARNING: 'execution_timeout' is deprecated for 'nb_execution_timeout' [mystnb.config]
WARNING: 'execution_in_temp' is deprecated for 'nb_execution_in_temp' [mystnb.config]
WARNING: 'execution_allow_errors' is deprecated for 'nb_execution_allow_errors' [mystnb.config]
myst-nb v0.16.0: NbParserConfig(custom_formats={}, metadata_key='mystnb', cell_metadata_key='mystnb', kernel_rgx_aliases={}, execution_mode='force', execution_cache_path='', execution_excludepatterns=[], execution_timeout=30, execution_in_temp=False, execution_allow_errors=False, execution_raise_on_error=False, execution_show_tb=False, merge_streams=False, render_plugin='default', remove_code_source=False, remove_code_outputs=False, number_source_lines=False, output_stderr='show', render_text_lexer='myst-ansi', render_error_lexer='ipythontb', render_image_options={}, render_figure_options={}, render_markdown_format='commonmark', output_folder='build', append_css=True, metadata_to_fm=False)
Using jupyter-cache at: /mnt/q/chaos-mirror/sample-book/_build/.jupyter_cache
building [mo]: targets for 0 po files that are out of date
building [singlehtml]: all documents
updating environment: [new config] 4 added, 0 changed, 0 removed
/mnt/q/chaos-mirror/sample-book/markdown-notebooks.md: Executing notebook using local CWD [mystnb]
/mnt/q/chaos-mirror/sample-book/markdown-notebooks.md: Executed notebook in 1.05 seconds [mystnb]
/mnt/q/chaos-mirror/sample-book/notebooks.ipynb: Executing notebook using local CWD [mystnb]
/mnt/q/chaos-mirror/sample-book/notebooks.ipynb: Executed notebook in 1.65 seconds [mystnb]

looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
assembling single document... markdown notebooks markdown-notebooks done
writing... failed

Theme error:
An error happened in rendering the page intro.
Reason: TemplateNotFound('_templates/prev-next.html')
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/sphinx/builders/html/__init__.py", line 1095, in handle_page
    output = self.templates.render(templatename, ctx)
  File "/usr/local/lib/python3.8/dist-packages/sphinx/jinja2glue.py", line 189, in render
    return self.environment.get_template(template).render(context)
  File "/usr/local/lib/python3.8/dist-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.8/dist-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/usr/local/lib/python3.8/dist-packages/sphinx/themes/basic/page.html", line 10, in top-level template code
    {%- extends "layout.html" %}
  File "/usr/local/lib/python3.8/dist-packages/sphinx_book_theme/theme/sphinx_book_theme/layout.html", line 4, in top-level template code
    {% set is_single_page = (theme_single_page == True) or (theme_single_page == "True") %}
  File "/usr/local/lib/python3.8/dist-packages/pydata_sphinx_theme/theme/pydata_sphinx_theme/../pydata_sphinx_theme/layout.html", line 2, in top-level template code
    {%- import "static/webpack-macros.html" as _webpack with context %}
  File "/usr/local/lib/python3.8/dist-packages/sphinx/themes/basic/../basic/layout.html", line 170, in top-level template code
    {%- block content %}
  File "/usr/local/lib/python3.8/dist-packages/sphinx_book_theme/theme/sphinx_book_theme/layout.html", line 25, in block 'content'
    {{ super() }}
  File "/usr/local/lib/python3.8/dist-packages/jinja2/sandbox.py", line 393, in call
    return __context.call(__obj, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/pydata_sphinx_theme/theme/pydata_sphinx_theme/../pydata_sphinx_theme/layout.html", line 44, in block 'content'
    {% block docs_main %}
  File "/usr/local/lib/python3.8/dist-packages/sphinx_book_theme/theme/sphinx_book_theme/layout.html", line 56, in block 'docs_main'
    {% block docs_body %}
  File "/usr/local/lib/python3.8/dist-packages/sphinx_book_theme/theme/sphinx_book_theme/layout.html", line 84, in block 'docs_body'
    {% include "sections/footer-article.html" %}
  File "/usr/local/lib/python3.8/dist-packages/sphinx_book_theme/theme/sphinx_book_theme/sections/footer-article.html", line 3, in top-level template code
    {% include "_templates/prev-next.html" %}
  File "/usr/local/lib/python3.8/dist-packages/sphinx/jinja2glue.py", line 210, in get_source
    raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: _templates/prev-next.html

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/jupyter_book/sphinx.py", line 167, in build_sphinx
    app.build(force_all, filenames)
  File "/usr/local/lib/python3.8/dist-packages/sphinx/application.py", line 349, in build
    self.builder.build_update()
  File "/usr/local/lib/python3.8/dist-packages/sphinx/builders/__init__.py", line 298, in build_update
    self.build(['__all__'], to_build)
  File "/usr/local/lib/python3.8/dist-packages/sphinx/builders/__init__.py", line 367, in build
    self.write(docnames, list(updated_docnames), method)
  File "/usr/local/lib/python3.8/dist-packages/sphinx/builders/singlehtml.py", line 155, in write
    self.write_doc(self.config.root_doc, doctree)
  File "/usr/local/lib/python3.8/dist-packages/sphinx/builders/html/__init__.py", line 671, in write_doc
    self.handle_page(docname, ctx, event_arg=doctree)
  File "/usr/local/lib/python3.8/dist-packages/sphinx/builders/html/__init__.py", line 1102, in handle_page
    raise ThemeError(__("An error happened in rendering the page %s.\nReason: %r") %
sphinx.errors.ThemeError: An error happened in rendering the page intro.
Reason: TemplateNotFound('_templates/prev-next.html')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/jupyter-book", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/jupyter_book/cli/main.py", line 323, in build
    builder_specific_actions(
  File "/usr/local/lib/python3.8/dist-packages/jupyter_book/cli/main.py", line 531, in builder_specific_actions
    raise RuntimeError(_message_box(msg, color="red", doprint=False)) from result
RuntimeError:
===============================================================================

There was an error in building your book. Look above for the cause.

===============================================================================

root@LAPTOP-E0HT1CM9:/mnt/q/chaos-mirror/sample-book#

problem This is a problem for people starting to use jupyter book, because create is the first project one experiments with.

Reproduce the bug

jb create sample-book
cd sample-book
jupyter-book build . --builder pdfhtml

List your environment

root@LAPTOP-E0HT1CM9:/mnt/q/chaos-mirror/sample-book# jupyter-book --version
Jupyter Book      : 0.13.0
External ToC      : 0.2.4
MyST-Parser       : 0.18.0
MyST-NB           : 0.16.0
Sphinx Book Theme : 0.3.3
Jupyter-Cache     : 0.5.0
NbClient          : 0.5.13

epogrebnyak avatar Aug 13 '22 06:08 epogrebnyak

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:

welcome[bot] avatar Aug 13 '22 06:08 welcome[bot]

It appears the bug is not specific to pdfhtml builder - simply jb build . fails as well.

issue A: _config.yml shoud have:

sphinx:
  config:
    language: en

issue B: Reason: TemplateNotFound('_templates/prev-next.html')

root@LAPTOP-E0HT1CM9:~/tmp_book# jb build .
Running Jupyter-Book v0.13.0
Source Folder: /root/tmp_book
Config Path: /root/tmp_book/_config.yml
Output Path: /root/tmp_book/_build/html
Running Sphinx v5.1.1
[etoc] Changing master_doc to 'intro'
checking bibtex cache... out of date
parsing bibtex file /root/tmp_book/references.bib... parsed 5 entries
myst v0.18.0: MdParserConfig(commonmark_only=False, gfm_only=False, enable_extensions=['colon_fence', 'dollarmath', 'linkify', 'substitution', 'tasklist'], disable_syntax=[], all_links_external=False, url_schemes=['mailto', 'http', 'https'], ref_domains=None, highlight_code_blocks=True, number_code_blocks=[], title_to_header=False, heading_anchors=None, heading_slug_func=None, footnote_transition=True, words_per_minute=200, sub_delimiters=('{', '}'), linkify_fuzzy_links=True, dmath_allow_labels=True, dmath_allow_space=True, dmath_allow_digits=True, dmath_double_inline=False, update_mathjax=True, mathjax_classes='tex2jax_process|mathjax_process|math|output_area')
WARNING: 'jupyter_execute_notebooks' is deprecated for 'nb_execution_mode' [mystnb.config]
WARNING: 'jupyter_cache' is deprecated for 'nb_execution_cache_path' [mystnb.config]
WARNING: 'execution_excludepatterns' is deprecated for 'nb_execution_excludepatterns' [mystnb.config]
WARNING: 'execution_timeout' is deprecated for 'nb_execution_timeout' [mystnb.config]
WARNING: 'execution_in_temp' is deprecated for 'nb_execution_in_temp' [mystnb.config]
WARNING: 'execution_allow_errors' is deprecated for 'nb_execution_allow_errors' [mystnb.config]
myst-nb v0.16.0: NbParserConfig(custom_formats={}, metadata_key='mystnb', cell_metadata_key='mystnb', kernel_rgx_aliases={}, execution_mode='force', execution_cache_path='', execution_excludepatterns=[], execution_timeout=30, execution_in_temp=False, execution_allow_errors=False, execution_raise_on_error=False, execution_show_tb=False, merge_streams=False, render_plugin='default', remove_code_source=False, remove_code_outputs=False, number_source_lines=False, output_stderr='show', render_text_lexer='myst-ansi', render_error_lexer='ipythontb', render_image_options={}, render_figure_options={}, render_markdown_format='commonmark', output_folder='build', append_css=True, metadata_to_fm=False)
Using jupyter-cache at: /root/tmp_book/_build/.jupyter_cache
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 4 source files that are out of date
updating environment: [new config] 4 added, 0 changed, 0 removed
/root/tmp_book/markdown-notebooks.md: Executing notebook using local CWD [mystnb]
/root/tmp_book/markdown-notebooks.md: Executed notebook in 1.43 seconds [mystnb]
/root/tmp_book/notebooks.ipynb: Executing notebook using local CWD [mystnb]
/root/tmp_book/notebooks.ipynb: Executed notebook in 2.48 seconds [mystnb]

looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [ 25%] intro
Theme error:
An error happened in rendering the page intro.
Reason: TemplateNotFound('_templates/prev-next.html')
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/sphinx/builders/html/__init__.py", line 1095, in handle_page
    output = self.templates.render(templatename, ctx)
  File "/usr/local/lib/python3.8/dist-packages/sphinx/jinja2glue.py", line 189, in render
    return self.environment.get_template(template).render(context)
  File "/usr/local/lib/python3.8/dist-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.8/dist-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/usr/local/lib/python3.8/dist-packages/sphinx/themes/basic/page.html", line 10, in top-level template code
    {%- extends "layout.html" %}
  File "/usr/local/lib/python3.8/dist-packages/sphinx_book_theme/theme/sphinx_book_theme/layout.html", line 4, in top-level template code
    {% set is_single_page = (theme_single_page == True) or (theme_single_page == "True") %}
  File "/usr/local/lib/python3.8/dist-packages/pydata_sphinx_theme/theme/pydata_sphinx_theme/../pydata_sphinx_theme/layout.html", line 2, in top-level template code
    {%- import "static/webpack-macros.html" as _webpack with context %}
  File "/usr/local/lib/python3.8/dist-packages/sphinx/themes/basic/../basic/layout.html", line 170, in top-level template code
    {%- block content %}
  File "/usr/local/lib/python3.8/dist-packages/sphinx_book_theme/theme/sphinx_book_theme/layout.html", line 25, in block 'content'
    {{ super() }}
  File "/usr/local/lib/python3.8/dist-packages/jinja2/sandbox.py", line 393, in call
    return __context.call(__obj, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/pydata_sphinx_theme/theme/pydata_sphinx_theme/../pydata_sphinx_theme/layout.html", line 44, in block 'content'
    {% block docs_main %}
  File "/usr/local/lib/python3.8/dist-packages/sphinx_book_theme/theme/sphinx_book_theme/layout.html", line 56, in block 'docs_main'
    {% block docs_body %}
  File "/usr/local/lib/python3.8/dist-packages/sphinx_book_theme/theme/sphinx_book_theme/layout.html", line 84, in block 'docs_body'
    {% include "sections/footer-article.html" %}
  File "/usr/local/lib/python3.8/dist-packages/sphinx_book_theme/theme/sphinx_book_theme/sections/footer-article.html", line 3, in top-level template code
    {% include "_templates/prev-next.html" %}
  File "/usr/local/lib/python3.8/dist-packages/sphinx/jinja2glue.py", line 210, in get_source
    raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: _templates/prev-next.html

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/jupyter_book/sphinx.py", line 167, in build_sphinx
    app.build(force_all, filenames)
  File "/usr/local/lib/python3.8/dist-packages/sphinx/application.py", line 349, in build
    self.builder.build_update()
  File "/usr/local/lib/python3.8/dist-packages/sphinx/builders/__init__.py", line 301, in build_update
    self.build(to_build,
  File "/usr/local/lib/python3.8/dist-packages/sphinx/builders/__init__.py", line 367, in build
    self.write(docnames, list(updated_docnames), method)
  File "/usr/local/lib/python3.8/dist-packages/sphinx/builders/__init__.py", line 559, in write
    self._write_serial(sorted(docnames))
  File "/usr/local/lib/python3.8/dist-packages/sphinx/builders/__init__.py", line 569, in _write_serial
    self.write_doc(docname, doctree)
  File "/usr/local/lib/python3.8/dist-packages/sphinx/builders/html/__init__.py", line 671, in write_doc
    self.handle_page(docname, ctx, event_arg=doctree)
  File "/usr/local/lib/python3.8/dist-packages/sphinx/builders/html/__init__.py", line 1102, in handle_page
    raise ThemeError(__("An error happened in rendering the page %s.\nReason: %r") %
sphinx.errors.ThemeError: An error happened in rendering the page intro.
Reason: TemplateNotFound('_templates/prev-next.html')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/jb", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/jupyter_book/cli/main.py", line 323, in build
    builder_specific_actions(
  File "/usr/local/lib/python3.8/dist-packages/jupyter_book/cli/main.py", line 531, in builder_specific_actions
    raise RuntimeError(_message_box(msg, color="red", doprint=False)) from result
RuntimeError:
===============================================================================

There was an error in building your book. Look above for the cause.

===============================================================================

epogrebnyak avatar Aug 13 '22 08:08 epogrebnyak