jupyter-notebook - nbsphinx 在构建 Jupyter Notebook 时导致构建失败

标签 jupyter-notebook jupyter python-sphinx read-the-docs

详细信息

我在阅读文档时遇到构建失败,我不明白。 nbsphinx.py 第 2151 行中的“逐字记录”断言导致构建失败。因此,当我尝试包含我创建的 Jupyter Notebook 教程时,构建失败。我将教程的当前版本与未导致构建失败的先前版本进行了比较,但我找不到可以解释当前失败的差异。

预期结果

包含 *.ipynb 文件的通过构建

实际结果

由于“Verbatim”断言失败,nbsphinx.py 第 2151 行构建失败。

终端输出:

Running Sphinx v4.1.2
loading translations [en]... done
making output directory... done
WARNING: html_static_path entry '_static' does not exist
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
building [latex]: all documents
updating environment: 0 added, 0 changed, 0 removed
looking for now-outdated files... none found
processing lofti_gaia.tex... index installation tutorials/QuickStart tutorials/Tutorial api lofti loftitools 
resolving references...
done
writing... failed

Exception occurred:
  File "/home/docs/checkouts/readthedocs.org/user_builds/lofti-gaia/conda/latest/lib/python3.7/site-packages/nbsphinx.py", line 2151, in depart_codearea_latex
    assert 'Verbatim' in lines[0]
AssertionError
The full traceback has been saved in /tmp/sphinx-err-x1h83s3m.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!

最佳答案

根据 nbsphinx 的 github 问题 584 (https://github.com/spatialaudio/nbsphinx/issues/584),这是由于 sphinx 4.1.0 的兼容性问题。可以通过要求 sphinx 版本 4.0.2 来绕过它。

因此,在我的 requirements.txt 文件中,我包含了 sphinx==4.0.2,之后构建就通过了。现在我的 requirements.txt 文件如下所示:

numpy
matplotlib
astropy>=4.0.1.post1
astroquery>=0.4
sphinx==4.0.2
ipython==7.19.0
nbsphinx>=0.8.6

以及构建过程。

关于jupyter-notebook - nbsphinx 在构建 Jupyter Notebook 时导致构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68642540/

相关文章:

python - 关于 toctree 引用的警告

python - 如何从 Jupyter Notebook 下载(保存)所有代码?

python - 图表未在 Web 浏览器中显示 |阴谋 | Python

python-3.x - 无法在 Windows 7 中从 cmd 启动 Jupyter 实验室

jupyter-notebook - 嵌套编号列表不会在 Jupyter Notebook Markdown 中换行

python - 在 Sphinx 扩展中获取源 .rst 文件路径

python - 设置 PYSPARK_SUBMIT_ARGS 后 PySpark 在 Jupyter 中失败

pyspark - 未找到 Spark Cell 魔法

python - 如果Python中的函数发生错误,有什么方法可以访问变量的值吗?

Python:在单个模块上使用 Sphinx 生成 autodoc?