jupyter-book
jupyter-book copied to clipboard
Building book at the project root fails
Describe the bug
context I was manually creating a jupyter-book for a repository, which sole purpose was to be a jupyter-book (i.e. no other code). When creating a jupyter-book at the root of a project, build fails.
expectation I expected the build to succeed for a jupyter-book at the root of a project.
bug The build command executes files from some of the virtual environment at the root of the project. Some of those file cause the build to fails.
Error output:
$ jb build .
Running Jupyter-Book v0.13.1
Source Folder: /home/math/test
Config Path: /home/math/test/_config.yml
Output Path: /home/math/test/_build/html
Running Sphinx v4.5.0
[etoc] Changing master_doc to 'intro'
checking bibtex cache... out of date
parsing bibtex file /home/math/test/references.bib... parsed 5 entries
myst v0.15.2: MdParserConfig(renderer='sphinx', commonmark_only=False, enable_extensions=['colon_fence', 'dollarmath', 'linkify', 'substitution', 'tasklist'], 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', disable_syntax=[], url_schemes=['mailto', 'http', 'https'], heading_anchors=None, heading_slug_func=None, html_meta=[], footnote_transition=True, substitutions=[], sub_delimiters=['{', '}'], words_per_minute=200)
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 298 source files that are out of date
updating environment: [new config] 298 added, 0 changed, 0 removed
Executing: .venv/lib/python3.11/site-packages/jupyter_book/book_template/markdown-notebooks in: /home/math/test/.venv/lib/python3.11/site-packages/jupyter_book/book_template
Executing: .venv/lib/python3.11/site-packages/jupyter_book/book_template/notebooks in: /home/math/test/.venv/lib/python3.11/site-packages/jupyter_book/book_template
Executing: .venv/lib/python3.11/site-packages/nbclassic/bundler/tests/resources/empty in: /home/math/test/.venv/lib/python3.11/site-packages/nbclassic/bundler/tests/resources
Executing: .venv/lib/python3.11/site-packages/nbclient/tests/files/Autokill in: /home/math/test/.venv/lib/python3.11/site-packages/nbclient/tests/files
/home/math/test/.venv/lib/python3.11/site-packages/jupyter_book/book_template/intro.md:: WARNING: tableofcontents directive in document with no descendants [etoc.tableofcontents]
ERROR: Execution Failed with traceback saved in /home/math/test/_build/html/reports/notebooks.log
Exception occurred:
File "/home/math/test/.venv/lib/python3.11/site-packages/nbclient/client.py", line 953, in async_execute_cell
raise DeadKernelError("Kernel died")
nbclient.exceptions.DeadKernelError: Kernel died
The full traceback has been saved in /tmp/sphinx-err-awcpmo8w.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
Traceback (most recent call last):
File "/home/math/test/.venv/lib/python3.11/site-packages/nbclient/client.py", line 949, in async_execute_cell
exec_reply = await self.task_poll_for_reply
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/math/test/.venv/lib/python3.11/site-packages/nbclient/client.py", line 730, in _async_poll_for_reply
msg = await ensure_async(self.kc.shell_channel.get_msg(timeout=new_timeout))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/math/test/.venv/lib/python3.11/site-packages/nbclient/util.py", line 96, in ensure_async
result = await obj
^^^^^^^^^
File "/home/math/test/.venv/lib/python3.11/site-packages/jupyter_client/channels.py", line 310, in get_msg
ready = await self.socket.poll(timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/math/test/.venv/lib/python3.11/site-packages/jupyter_book/sphinx.py", line 171, in build_sphinx
app.build(force_all, filenames)
File "/home/math/test/.venv/lib/python3.11/site-packages/sphinx/application.py", line 330, in build
self.builder.build_update()
File "/home/math/test/.venv/lib/python3.11/site-packages/sphinx/builders/__init__.py", line 286, in build_update
self.build(to_build,
File "/home/math/test/.venv/lib/python3.11/site-packages/sphinx/builders/__init__.py", line 300, in build
updated_docnames = set(self.read())
^^^^^^^^^^^
File "/home/math/test/.venv/lib/python3.11/site-packages/sphinx/builders/__init__.py", line 407, in read
self._read_serial(docnames)
File "/home/math/test/.venv/lib/python3.11/site-packages/sphinx/builders/__init__.py", line 428, in _read_serial
self.read_doc(docname)
File "/home/math/test/.venv/lib/python3.11/site-packages/sphinx/builders/__init__.py", line 468, in read_doc
doctree = read_doc(self.app, self.env, self.env.doc2path(docname))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/math/test/.venv/lib/python3.11/site-packages/sphinx/io.py", line 181, in read_doc
pub.publish()
File "/home/math/test/.venv/lib/python3.11/site-packages/docutils/core.py", line 217, in publish
self.document = self.reader.read(self.source, self.parser,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/math/test/.venv/lib/python3.11/site-packages/sphinx/io.py", line 101, in read
self.parse()
File "/home/math/test/.venv/lib/python3.11/site-packages/docutils/readers/__init__.py", line 78, in parse
self.parser.parse(self.input, document)
File "/home/math/test/.venv/lib/python3.11/site-packages/myst_nb/parser.py", line 67, in parse
ntbk = generate_notebook_outputs(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/math/test/.venv/lib/python3.11/site-packages/myst_nb/execution.py", line 137, in generate_notebook_outputs
result = single_nb_execution(
^^^^^^^^^^^^^^^^^^^^
File "/home/math/test/.venv/lib/python3.11/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
executenb(
File "/home/math/test/.venv/lib/python3.11/site-packages/nbclient/client.py", line 1204, in execute
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/math/test/.venv/lib/python3.11/site-packages/nbclient/util.py", line 84, in wrapped
return just_run(coro(*args, **kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/math/test/.venv/lib/python3.11/site-packages/nbclient/util.py", line 62, in just_run
return loop.run_until_complete(coro)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/math/.pyenv/versions/3.11.0/lib/python3.11/asyncio/base_events.py", line 650, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/home/math/.pyenv/versions/3.11.0/lib/python3.11/contextlib.py", line 222, in __aexit__
await self.gen.athrow(typ, value, traceback)
File "/home/math/test/.venv/lib/python3.11/site-packages/nbclient/client.py", line 611, in async_setup_kernel
raise e
File "/home/math/test/.venv/lib/python3.11/site-packages/nbclient/client.py", line 608, in async_setup_kernel
yield
File "/home/math/test/.venv/lib/python3.11/site-packages/nbclient/client.py", line 663, in async_execute
await self.async_execute_cell(
File "/home/math/test/.venv/lib/python3.11/site-packages/nbclient/client.py", line 953, in async_execute_cell
raise DeadKernelError("Kernel died")
nbclient.exceptions.DeadKernelError: Kernel died
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/math/test/.venv/bin/jb", line 8, in <module>
sys.exit(main())
^^^^^^
File "/home/math/test/.venv/lib/python3.11/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/math/test/.venv/lib/python3.11/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/home/math/test/.venv/lib/python3.11/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/math/test/.venv/lib/python3.11/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/math/test/.venv/lib/python3.11/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/math/test/.venv/lib/python3.11/site-packages/jupyter_book/cli/main.py", line 323, in build
builder_specific_actions(
File "/home/math/test/.venv/lib/python3.11/site-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.
===============================================================================
problem Currently the users is forced to create a jupyter-book into a sub-folder of their project.
Reproduce the bug
Steps to reproduce:
$ python -m venv .venv
$ source .venv/bin/activate
$ pip install jupyter-book
$ jb create docs
$ mv docs/* . && rmdir docs
$ jb build .
List your environment
$ jb --version
Jupyter Book : 0.13.1
External ToC : 0.2.4
MyST-Parser : 0.15.2
MyST-NB : 0.13.2
Sphinx Book Theme : 0.3.3
Jupyter-Cache : 0.4.3
NbClient : 0.5.13
Python version:
$ python -V
Python 3.11.0
OS: WSL (Ubuntu)
$ cat /etc/os-release | grep VERSION=
VERSION="22.04.1 LTS (Jammy Jellyfish)"
No other tools used.
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:
Something that worked for me is excluding the virtual environment folder in _config.yml and only building what is listed in _toc.yml file.
Added the following entries to _config.yml (".venv" is my virtual environment):
exclude_patterns: [_build, "**.ipynb_checkpoints", ".venv/*"]
only_build_toc_files: true