le8rning
le8rning

Reputation: 145

jupyter nbconvert --to html_toc not working (convert jupyter notebook with table of content to website format)

What I wanted

With the nbextension toc, jupyter notebooks have table of content capabilities which is said to be transferable to html via nbconvert --to html_toc function, or via the dropdown menue "download as html with toc". However, neither option works in my case.

What I have tried

  1. Download as html with toc initially gave an error similar to TemplateNotFound: toc2
  2. All recommended commands like jupyter nbconvert FILE.ipynb --template toc jupyter nbconvert FILE.ipynb --template toc2 (These two appear to be incomplete but are supplied like this) jupyter nbconvert --to html_toc FILE.ipynb (same error as above via menue)
  3. As here and here the toc2.tpl file is mentioned, I placed this file together with the main.css and toc2.js file into the same directory as the ipynb notebook to be converted. Now the download as html with toc menue gives error "nbconvert failed: toc2" and the jupyter nbconvert FILE.ipynb --template toc2 gives error "jinja2.exceptions.TemplateNotFound: toc2" I still have not understood the role of the toc2 template. Is it (still) necessary? Why? How (with the other files?)? Where (how is the location provided)? What exactly is needed where and how to make use of this extremely usefull functionality?
  4. The downgrade mentioned here was not possible due to resulting incompab.

Used Conditions / Versions in conda virtual environment

(Please tell me if you need more information)

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

Upvotes: 6

Views: 6949

Answers (2)

Joab
Joab

Reputation: 11

You can try running the following command:

pip install "nbconvert<6"

Then check that it installed nbconvert-5.6.1 (5.6.1 version).

After that, execute the following:

jupyter nbconvert --to html_toc YOURFILENAME.ipynb

Upvotes: 1

Jaeyoung Chun
Jaeyoung Chun

Reputation: 671

This workaround worked for me:

pip install "nbconvert<6"

Upvotes: 3

Related Questions