Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

python - How can I get the option 'Export Notebook to Html_toc' on the 'Export Notebook as...' menu in Jupyter Lab?

  • 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:
    • enter image description here
  • 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:
    • enter image description here
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
  • 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
    • enter image description here
  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.
    • enter image description here
  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.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...