How to export current notebook in HTML on Jupyter

后端 未结 3 1637
渐次进展
渐次进展 2021-02-04 02:03

How can I export the current notebook (from inside the notebook itself, using Python) to HTML (to a custom output path)?

相关标签:
3条回答
  • 2021-02-04 02:24

    You can do it. Use the following very simple steps:

    I am using: OS: Ubuntu, Anaconda-Jupyter notebook, Python 3

    1 Save your Notebook in HTML format:

    1. Start the jupyter notebook that you want to save in HTML format. First save the notebook properly so that HTML file will have a latest saved version of your code/notebook.

    2. Run the following command from the notebook itself:

      !jupyter nbconvert --to html your_notebook_name.ipynb

    Edit: or you can also use: !jupyter nbconvert your_notebook_name.ipynb --to html

    After execution will create HTML version of your notebook and will save it in the current working directory. You will see one html file will be added into the current directory with your_notebook_name.html name

    (your_notebook_name.ipynb --> your_notebook_name.html).

    If you want to know how to save it into pdf format please check my answer on this question as well: IPython notebook - unable to export to pdf

    0 讨论(0)
  • 2021-02-04 02:46

    By looking at nbconvert docs, you'll see that you can use --to html method:

    import os
    
    os.system('jupyter nbconvert --to html yourNotebook.ipynb')
    

    This will create a yourNotebook.html file inside yourNotebook.ipynb folder.

    0 讨论(0)
  • 2021-02-04 02:47

    Actually you need to save your notebook first, then you can use the nbconvert command

    It would be something like:

    %%javascript
    IPython.notebook.save_notebook()
    

    And Then

    import os
    os.system('jupyter nbconvert --to html yourNotebook.ipynb')
    

    If you do not do this, it will not convert the actual notebook.

    0 讨论(0)
提交回复
热议问题