[英]How export a Jupyter notebook to HTML from the command line?
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. 我想通过终端运行jupyter笔记本并生成html页面以向用户显示它而不向用户显示可编辑脚本。 Can I do that? 我能这样做吗? Or suggest the better way to show visualized test results. 或者建议更好的方式来显示可视化的测试结果。
Also use --execute
to get the output 还可以使用--execute
来获取输出
jupyter nbconvert --execute --to html notebook.ipynb
This produces a notebook.html
file. 这会生成一个notebook.html
文件。
The best practice is to keep the output out of the notebook for version control, see: Using IPython notebooks under version control 最佳做法是将输出保留在笔记本中以进行版本控制,请参阅: 在版本控制下使用IPython笔记本
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? 但是,如果你没有传递--execute
,输出将不会出现在HTML中,另请参阅: 如何从终端运行.ipynb Jupyter Notebook?
For an HTML fragment without header: How to export an IPython notebook to HTML for a blog post? 对于没有标题的HTML片段: 如何将IPython笔记本导出为HTML以用于博客文章?
Tested in Jupyter 4.4.0. 在Jupyter 4.4.0中测试过。
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. 这将生成一个notebook.html文件。 Output can be customized . 输出可以定制 。 Also check out the slideshow functionality (View>Cell-Toolbar>Slideshow) which can also be used with nbconvert. 另请参阅幻灯片功能(视图>单元工具栏>幻灯片),它也可以与nbconvert一起使用。
Also the notebook.ipynb Jupyter file can be uploaded to Github where the current version gets rendered. notebook.ipynb Jupyter文件也可以上传到当前版本呈现的Github。 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: 您可以直接在jupyter单元格中运行bash命令,如下所示:
%%bash
convert graphviz/MyPic.jpg -resize 70% graphviz/MyPic_sm.jpg
I developed jupyter-runner ( https://github.com/omar-masmoudi/jupyter-runner ) which is a simple wrapper around "jupyter nbconvert". 我开发了jupyter-runner( https://github.com/omar-masmoudi/jupyter-runner ),这是一个围绕“jupyter nbconvert”的简单包装器。
Several notebooks can be executed, with parameters, with parallel workers, input/output located in S3 and mail sending capabilities. 可以使用参数,并行工作程序,位于S3中的输入/输出和邮件发送功能来执行多个笔记本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.