Unable to use jupyterlite-sphinx with Jupyterbook after package upgrades (anymore)
Closed this issue · 3 comments
Description
Due to some version upgrades (unfortunately I can't remember the previous system states on packages), I am no longer able to use jupyterlite-sphinx
with Jupyter Book. I was able to get this working before I did some package upgrades but am not able to reproduce:
Reproduce
Here are some steps to reproduce:
- Clone this repo:
git clone https://github.com/firasm/jb_jblite_jupyterlabdeck.git
- Run Jupyterbook:
jb build jb_jblite_jupyterlabdeck
Expected behavior
I expect Jupyterlite to be embedded into my JupyterBook.
Context
The error seems to occur because "jupyter-lite" cannot be found:
[jupyterlite-sphinx] Running JupyterLite build
usage: jupyter [-h] [--version] [--config-dir] [--data-dir] [--runtime-dir] [--paths] [--json] [--debug] [subcommand]
Jupyter: Interactive Computing
positional arguments:
subcommand the subcommand to launch
options:
-h, --help show this help message and exit
--version show the versions of core jupyter packages and exit
--config-dir show Jupyter config dir
--data-dir show Jupyter data dir
--runtime-dir show Jupyter runtime dir
--paths show all Jupyter paths. Add --json for machine-readable format.
--json output paths as machine-readable json
--debug output debug information about paths
Available subcommands: book bundlerextension console contrib dejavu events execute fileid kernel kernelspec lab labextension labhub migrate nbclassic
nbconvert nbextension nbextensions_configurator notebook nteract piplite qtconsole run server serverextension theme troubleshoot trust
Jupyter command `jupyter-lite` not found.
- JupyterLite version:
0.1.0rc0
- Jupyterlite-sphinx version:
0.8.0
- Operating System and version:
macOS 13.3 (22E252)
- Browser and version: Safari, Brave, Vivaldi (etc...)
Full JupyterBook Export
▶ jb build .
Running Jupyter-Book v0.15.1
Source Folder: /Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck
Config Path: /Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/_config.yml
Output Path: /Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/_build/html
Running Sphinx v5.0.2
[etoc] Changing master_doc to 'demo'
checking bibtex cache... out of date
parsing bibtex file /Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/references.bib... WARNING: could not open bibtex file /Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/references.bib.
myst v0.18.1: 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')
myst-nb v0.17.1: 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, code_prompt_show='Show code cell {type}', code_prompt_hide='Hide code cell {type}', 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: /Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/_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
/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/_contents/notebook.ipynb: Executing notebook using local CWD [mystnb]
/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/_contents/notebook.ipynb: Executed notebook in 2.00 seconds [mystnb]
/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/notebook.ipynb: Executing notebook using local CWD [mystnb]
/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/notebook.ipynb: Executed notebook in 1.70 seconds [mystnb]
looking for now-outdated files... none found
pickling environment... done
checking consistency... /Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/_contents/notebook.ipynb: WARNING: document isn't included in any toctree
/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/notebook.ipynb: WARNING: document isn't included in any toctree
done
preparing documents... done
writing output... [100%] notebook
generating indices... genindex done
writing additional pages... search done
copying static files... done
copying extra files... done
dumping search index in English (code: en)... done
dumping object inventory... done
[jupyterlite-sphinx] Running JupyterLite build
usage: jupyter [-h] [--version] [--config-dir] [--data-dir] [--runtime-dir] [--paths] [--json] [--debug] [subcommand]
Jupyter: Interactive Computing
positional arguments:
subcommand the subcommand to launch
options:
-h, --help show this help message and exit
--version show the versions of core jupyter packages and exit
--config-dir show Jupyter config dir
--data-dir show Jupyter data dir
--runtime-dir show Jupyter runtime dir
--paths show all Jupyter paths. Add --json for machine-readable format.
--json output paths as machine-readable json
--debug output debug information about paths
Available subcommands: book bundlerextension console contrib dejavu events execute fileid kernel kernelspec lab labextension labhub migrate nbclassic
nbconvert nbextension nbextensions_configurator notebook nteract piplite qtconsole run server serverextension theme troubleshoot trust
Jupyter command `jupyter-lite` not found.
Extension error (jupyterlite_sphinx.jupyterlite_sphinx):
Handler <function jupyterlite_build at 0x11159aef0> for event 'build-finished' threw an exception (exception: Command '['jupyter', 'lite', 'build', '--debug', '--contents', '/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/_contents', '--output-dir', '/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/_build/html/lite', '--lite-dir', '/var/folders/64/bfv2dn992m17r4ztvfrt93rh0000gn/T/tmpjd89lt99']' returned non-zero exit status 1.)
Traceback (most recent call last):
File "/Users/firasm/.pyenv/versions/3.10.2/lib/python3.10/site-packages/sphinx/events.py", line 94, in emit
results.append(listener.handler(self.app, *args))
File "/Users/firasm/.pyenv/versions/3.10.2/lib/python3.10/site-packages/jupyterlite_sphinx/jupyterlite_sphinx.py", line 341, in jupyterlite_build
subprocess.run(command, check=True)
File "/Users/firasm/.pyenv/versions/3.10.2/lib/python3.10/subprocess.py", line 524, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['jupyter', 'lite', 'build', '--debug', '--contents', '/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/_contents', '--output-dir', '/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/_build/html/lite', '--lite-dir', '/var/folders/64/bfv2dn992m17r4ztvfrt93rh0000gn/T/tmpjd89lt99']' returned non-zero exit status 1.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/firasm/.pyenv/versions/3.10.2/lib/python3.10/site-packages/jupyter_book/sphinx.py", line 171, in build_sphinx
app.build(force_all, filenames)
File "/Users/firasm/.pyenv/versions/3.10.2/lib/python3.10/site-packages/sphinx/application.py", line 331, in build
self.events.emit('build-finished', None)
File "/Users/firasm/.pyenv/versions/3.10.2/lib/python3.10/site-packages/sphinx/events.py", line 102, in emit
raise ExtensionError(__("Handler %r for event %r threw an exception") %
sphinx.errors.ExtensionError: Handler <function jupyterlite_build at 0x11159aef0> for event 'build-finished' threw an exception (exception: Command '['jupyter', 'lite', 'build', '--debug', '--contents', '/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/_contents', '--output-dir', '/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/_build/html/lite', '--lite-dir', '/var/folders/64/bfv2dn992m17r4ztvfrt93rh0000gn/T/tmpjd89lt99']' returned non-zero exit status 1.)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/firasm/.pyenv/versions/3.10.2/bin/jb", line 8, in <module>
sys.exit(main())
File "/Users/firasm/.pyenv/versions/3.10.2/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
return self.main(*args, **kwargs)
File "/Users/firasm/.pyenv/versions/3.10.2/lib/python3.10/site-packages/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/Users/firasm/.pyenv/versions/3.10.2/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/firasm/.pyenv/versions/3.10.2/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/firasm/.pyenv/versions/3.10.2/lib/python3.10/site-packages/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/Users/firasm/.pyenv/versions/3.10.2/lib/python3.10/site-packages/jupyter_book/cli/main.py", line 317, in build
builder_specific_actions(
File "/Users/firasm/.pyenv/versions/3.10.2/lib/python3.10/site-packages/jupyter_book/cli/main.py", line 525, 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.
===============================================================================
Would love any assistance to get this working!
Thanks @firasm for the report.
I just tried in a fresh new environment (on Gitpod) with:
pip install jupyter-book jupyterlite-sphinx
jb build .
python -m http.server
And it seem to build fine:
Also note that with newer versions of jupyterlite-sphinx
you need to install a kernel explicitly: https://github.com/jupyterlite/jupyterlite-sphinx/blob/main/CHANGELOG.md#080
Hmmm okay thanks a lot for the sanity check @jtpio - I was able to reproduce it working on gitpod.
Locally, I tried creating a fresh environment after (uninstalling a bunch of packages):
python -m venv fresh3
pip install jupyter-book jupyterlite-sphinx jupyterlite-pyodide-kernel
But now I get a different error ("Kernel died") while trying to build the book (so, progress I guess!):
(fresh3)
Sync/Hacking/jb_jblite_jupyterlabdeck main ✗ 13h46m ◒
▶ jb build .
Running Jupyter-Book v0.15.1
Source Folder: /Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck
Config Path: /Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/_config.yml
Output Path: /Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/_build/html
[sphinxcontrib-bibtex] Beware that docutils versions 0.18 and 0.19 (you are running 0.18.1) are known to generate invalid html for citations. If this issue affects you, please use docutils<0.18 (or >=0.20 once released) instead. For more details, see https://sourceforge.net/p/docutils/patches/195/
Running Sphinx v5.0.2
[etoc] Changing master_doc to 'demo'
checking bibtex cache... out of date
parsing bibtex file /Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/references.bib... WARNING: could not open bibtex file /Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/references.bib.
myst v0.18.1: 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')
myst-nb v0.17.1: 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, code_prompt_show='Show code cell {type}', code_prompt_hide='Hide code cell {type}', 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: /Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/_build/.jupyter_cache
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 62 source files that are out of date
updating environment: [new config] 62 added, 0 changed, 0 removed
/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/_contents/notebook.ipynb: Executing notebook using local CWD [mystnb]
/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/jupyter_book/book_template/markdown-notebooks.md: Executing notebook using local CWD [mystnb]
/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/jupyter_book/book_template/markdown-notebooks.md: Executed notebook in 0.91 seconds [mystnb]
/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/jupyter_book/book_template/notebooks.ipynb: Executing notebook using local CWD [mystnb]
/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/nbclient/tests/files/Autokill.ipynb: Executing notebook using local CWD [mystnb]
/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/_contents/notebook.ipynb: WARNING: Executing notebook failed: CellExecutionError [mystnb.exec]
/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/_contents/notebook.ipynb: WARNING: Notebook exception traceback saved in: /Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/_build/html/reports/_contents/notebook.err.log [mystnb.exec]
/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/jupyter_book/book_template/intro.md:: WARNING: tableofcontents directive in document with no descendants [etoc.tableofcontents]
/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/jupyter_book/book_template/notebooks.ipynb: WARNING: Executing notebook failed: CellExecutionError [mystnb.exec]
/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/jupyter_book/book_template/notebooks.ipynb: WARNING: Notebook exception traceback saved in: /Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/_build/html/reports/fresh3/lib/python3.8/site-packages/jupyter_book/book_template/notebooks.err.log [mystnb.exec]
Exception occurred:
File "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/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 /var/folders/64/bfv2dn992m17r4ztvfrt93rh0000gn/T/sphinx-err-3kgf10ev.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 "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/nbclient/client.py", line 949, in async_execute_cell
exec_reply = await self.task_poll_for_reply
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/jupyter_book/sphinx.py", line 171, in build_sphinx
app.build(force_all, filenames)
File "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/sphinx/application.py", line 329, in build
self.builder.build_update()
File "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/sphinx/builders/__init__.py", line 288, in build_update
self.build(to_build,
File "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/sphinx/builders/__init__.py", line 302, in build
updated_docnames = set(self.read())
File "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/sphinx/builders/__init__.py", line 409, in read
self._read_serial(docnames)
File "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/sphinx/builders/__init__.py", line 430, in _read_serial
self.read_doc(docname)
File "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/sphinx/builders/__init__.py", line 483, in read_doc
publisher.publish()
File "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/docutils/core.py", line 217, in publish
self.document = self.reader.read(self.source, self.parser,
File "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/sphinx/io.py", line 103, in read
self.parse()
File "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/docutils/readers/__init__.py", line 78, in parse
self.parser.parse(self.input, document)
File "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/myst_nb/sphinx_.py", line 150, in parse
with create_client(
File "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/myst_nb/core/execute/base.py", line 83, in __enter__
self.start_client()
File "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/myst_nb/core/execute/direct.py", line 40, in start_client
result = single_nb_execution(
File "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/jupyter_cache/executors/utils.py", line 58, in single_nb_execution
executenb(
File "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/nbclient/client.py", line 1204, in execute
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
File "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/nbclient/util.py", line 84, in wrapped
return just_run(coro(*args, **kwargs))
File "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/nbclient/util.py", line 62, in just_run
return loop.run_until_complete(coro)
File "/Users/firasm/.pyenv/versions/3.8.16/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/nbclient/client.py", line 663, in async_execute
await self.async_execute_cell(
File "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/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 "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/bin/jb", line 8, in <module>
sys.exit(main())
File "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/jupyter_book/cli/main.py", line 317, in build
builder_specific_actions(
File "/Users/firasm/Sync/Hacking/jb_jblite_jupyterlabdeck/fresh3/lib/python3.8/site-packages/jupyter_book/cli/main.py", line 525, 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.
===============================================================================
I will continue troubleshooting later today and report back ...
Okay I have solved this finally! The error above was arising because I created a venv
inside my jupyter book directory which caused files in the directory to be parsed and resulted in errors.
I still have the Jupyter command
jupyter-lite not found.
in my main environment despite doing pip freeze
in my fresh environment and installing those packages in my main environment but it's clear there's some weird interaction somewhere that's cause an issue.
Anyway since I have things working with a fresh environment I'll close this issue and see if I can resolve the main issue another time.
Thank you for your help and direction to try things in gitpod!!