How export a Jupyter notebook to HTML from the command line?

為{幸葍}努か 提交于 2020-05-24 15:37:26

问题


I'm writing test visualization program based on test results. I want to run jupyter notebook via terminal and generate html page to show it to user without showing the editable scripts to user. Can I do that? Or suggest the better way to show visualized test results.


回答1:


Also use --execute to get the output

jupyter nbconvert --execute --to html notebook.ipynb

This produces a notebook.html file.

The best practice is to keep the output out of the notebook for version control, see: Using IPython notebooks under version control

But then, if you don't pass --execute, the output won't be present in the HTML, see also: How to run an .ipynb Jupyter Notebook from terminal?

For an HTML fragment without header: How to export an IPython notebook to HTML for a blog post?

Tested in Jupyter 4.4.0.




回答2:


Yes you can and it's quite easy and a built in feature

jupyter nbconvert --to html notebook.ipynb

That will generate a notebook.html file. Output can be customized. Also check out the slideshow functionality (View>Cell-Toolbar>Slideshow) which can also be used with nbconvert.

Also the notebook.ipynb Jupyter file can be uploaded to Github where the current version gets rendered. Depending on what you want that information might be useful too

Also check out line/cell magic. You can run bash commands directly in your jupyter cell like so:

%%bash
convert graphviz/MyPic.jpg -resize 70% graphviz/MyPic_sm.jpg



回答3:


I developed jupyter-runner (https://github.com/omar-masmoudi/jupyter-runner) which is a simple wrapper around "jupyter nbconvert".

Several notebooks can be executed, with parameters, with parallel workers, input/output located in S3 and mail sending capabilities.



来源:https://stackoverflow.com/questions/36901154/how-export-a-jupyter-notebook-to-html-from-the-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!