【问题标题】:jupyter nbconvert --to html_toc not working (convert jupyter notebook with table of content to website format)jupyter nbconvert --to html_toc 不起作用(将带有目录的 jupyter notebook 转换为网站格式)
【发布时间】:2021-05-24 13:46:32
【问题描述】:

我想要什么

使用 nbextension toc,jupyter 笔记本具有目录功能,据说可以通过nbconvert --to html_toc function 或通过下拉菜单“下载为带有 toc 的 html”转换为 html。但是,这两个选项都不适用于我的情况。

我尝试过的

  1. 使用 toc 下载为 html 最初出现类似于 TemplateNotFound: toc2 的错误
  2. 所有推荐的命令,如 jupyter nbconvert FILE.ipynb --template toc jupyter nbconvert FILE.ipynb --template toc2(这两个似乎不完整,但提供如下) jupyter nbconvert --to html_toc FILE.ipynb(通过菜单与上述相同的错误)
  3. 由于herehere提到了toc2.tpl文件,我把这个文件和main.css和toc2.js文件一起放到了要转换的ipynb notebook同一个目录下。现在下载为带有 toc menue 的 html 会给出错误“nbconvert failed: toc2”,jupyter nbconvert FILE.ipynb --template toc2 会给出错误“jinja2.exceptions.TemplateNotFound: toc2” 我还没有理解toc2模板的作用。它(仍然)有必要吗?为什么?如何(与其他文件?)?在哪里(如何提供位置)?究竟需要在哪里以及如何使用这个非常有用的功能?
  4. 提到的降级 here 是不可能的,因为导致 incompab。

conda 虚拟环境中的使用条件/版本

(如果您需要更多信息,请告诉我)

jupyter core     : 4.7.1
jupyter-notebook : 6.2.0
qtconsole        : 5.0.2
ipython          : 7.20.0
ipykernel        : 5.3.4
jupyter client   : 6.1.7
jupyter lab      : 3.0.8
nbconvert        : 6.0.7
ipywidgets       : 7.6.3
nbformat         : 5.1.2
traitlets        : 5.0.5

【问题讨论】:

  • 我不知道我的问题是否相关,但我在nbconvert --execute 中缺少html 作为可用格式,并且papermill 也在产生垃圾(原始的.ipynb JSON,看起来)。它可能与 Python 3.9 有关 - 我在 Python 3.7 切换到较旧的 Conda env,并且转换为 HTML 工作正常。我认为这是一个会在未来一段时间内消失的错误。
  • 您好!到目前为止有什么改进吗?
  • @XopiGarcía 谢谢你的提问,但我没有进一步关注。目前还不够重要:)

标签: python jupyter jupyter-contrib-nbextensions


【解决方案1】:

这个解决方法对我有用:

pip install "nbconvert<6"

【讨论】:

  • 没有可能的解决方案,正如他所说:4. 提到的降级 here 是不可能的,因为导致 incompab。
【解决方案2】:

您可以尝试运行以下命令:

pip install "nbconvert<6"

然后检查它是否安装了nbconvert-5.6.1(5.6.1版本)

之后,执行以下操作:

jupyter nbconvert --to html_toc YOURFILENAME.ipynb

【讨论】:

    猜你喜欢
    • 2019-08-27
    • 2020-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-05
    • 2019-11-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多