【问题标题】:nbsphinx causes build to fail when building Jupyter Notebooks构建 Jupyter Notebook 时,nbsphinx 导致构建失败
【发布时间】:2021-08-03 20:40:19
【问题描述】:

详情

我的阅读文档构建失败,我不明白。 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!

【问题讨论】:

  • 请不要粘贴文字图片。而是粘贴实际的错误消息。

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


【解决方案1】:

根据 nbsphinx (https://github.com/spatialaudio/nbsphinx/issues/584) 的 github issue 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

构建通过。

【讨论】:

    【解决方案2】:

    我也遇到了同样的问题。我没有用 .ipynb 格式解决它,但是将 jupyter notebook 转换为 .rst 格式可以。

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 2019-11-01
      • 2019-09-21
      • 1970-01-01
      • 2015-09-05
      • 1970-01-01
      • 1970-01-01
      • 2022-08-09
      • 2021-11-30
      • 2015-02-07
      相关资源
      最近更新 更多