如何在 Jupyter Lab 的“将笔记本导出为..."菜单上获得“将笔记本导出到 Html_toc"选项? [英] How can I get the option 'Export Notebook to Html_toc' on the 'Export Notebook as...' menu in Jupyter Lab?

查看:36
本文介绍了如何在 Jupyter Lab 的“将笔记本导出为..."菜单上获得“将笔记本导出到 Html_toc"选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 如何从 Jupyter 实验室的 Export Notebook As... 菜单启用所有 jupyter nbconvert 导出选项?
    • 具体来说,我怎样才能在菜单上获得Export Notebook to Html_toc的选项?
  • 在全新安装 Anaconda 后,默认导出菜单为:
  • 但是,如本期所示

解决方案

  • 这个答案是在 Jupyter Lab 中启用完整菜单的迂回技巧
  • 在这种情况下,我全新安装了 Anaconda,其中包括 Jupyter Lab 和 Jupyter Notebook.
  • 进入 Jupyter 实验室后,只有最少的导出选项可用.

要启用 Html_toc 导出选项,请执行以下操作

  1. 转到 Jupyter Lab 中的扩展管理器并安装 @jupyterlab/toc
  2. 关闭 Jupyter 实验室并转到 Anaconda Prompt
  3. 根据
  4. 退出/退出 Jupyter Notebook
  5. 在 Anaconda 提示符下,转到 jupyter 实验室
  6. 现在所有 Export Notebook As... 选项都将在文件菜单中启用.
    • 包括,特别是将笔记本导出到 Html_toc

示例

  • How can all of the jupyter nbconvert export options be enabled from the Export Notebook As... menu in Jupyter lab?
    • Specifically, how can I get the option to Export Notebook to Html_toc on the menu?
  • Following a clean installation of Anaconda, the default export menu is:
  • However, as shown in this issue Add nbconvert export options to File --> Export notebook as #7612, there are additional options, which can be run from the console, but do not display in the menu.
  • The full menu would look like:

解决方案

  • This answer is a roundabout hack for enabling the full menu in Jupyter Lab
  • In this situation, I have a clean installation of Anaconda, which includes Jupyter Lab and Jupyter Notebook.
  • Upon entering Jupyter Lab, only the minimal Export options are available.

To enable the Html_toc Export option, do the following

  1. Go to the Extension Manager in Jupyter Lab and install @jupyterlab/toc
  2. Shut down Jupyter lab and go to the Anaconda Prompt
  3. Run conda install jupyter_contrib_nbextensions or conda install -c conda-forge jupyter_contrib_nbextensions per Installing jupyter_contrib_nbextensions Guide.
    • This will install a number of extensions to \Anaconda3\lib\site-packages\jupyter_contrib_nbextensions\nbextensions\
    • There are pip install options in the guide, but I haven't tried this for a manual installation of Jupyter Lab and Jupyter Notebook
  4. Run jupyter contrib nbextension install --user
  5. From the Anaconda Prompt, run jupyter notebook
    • During loading of the Jupyter Notebook environment, there where warnings as follows [jupyter_nbextensions_configurator] nbextension '...' has duplicate listings.
    • One location was \Anaconda3\..., as mentioned above, and the other was \Users\...\AppData\Roaming\jupyter\nbextensions\...
    • This could be because I had a previous installation of Anaconda, but I resolved this issue by renaming \Users\...\AppData\Roaming\jupyter\nbextensions\... to \Users\...\AppData\Roaming\jupyter\nbextensions_old\...
  6. Go to the Nvextensions tab, select the option for Table of Contents (2), and Enable it.
  7. Quit / Logout of Jupyter Notebook
  8. From the Anaconda prompt, go the jupyter lab
  9. Now all of the Export Notebook As... options will be enabled in the file menu.
    • Including, and specifically Export Notebook to Html_toc

Examples

  • Here are examples of HTML notebooks with a Table of Contents output from Jupyter Lab. See the DataCamp notebooks.

这篇关于如何在 Jupyter Lab 的“将笔记本导出为..."菜单上获得“将笔记本导出到 Html_toc"选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆