如何从命令行将Jupyter笔记本导出为HTML? [英] How export a Jupyter notebook to HTML from the command line?

查看:3001
本文介绍了如何从命令行将Jupyter笔记本导出为HTML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在根据测试结果编写测试可视化程序. 我想通过终端运行jupyter笔记本并生成html页面以向用户显示,而不向用户显示可编辑的脚本. 我可以那样做吗?或建议一种更好的方式来显示可视化的测试结果.

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.

推荐答案

也使用--execute获取输出

Also use --execute to get the output

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

这将生成一个notebook.html文件.

最佳做法是将输出保留在笔记本之外以进行版本控制,请参阅:在版本控制下使用IPython笔记本

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

但是,如果您不通过--execute,则输出将不会出现在HTML中,另请参见:

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?

对于不带标题的HTML片段:如何将IPython Notebook导出为HTML撰写博客文章?

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

在Jupyter 4.4.0中进行了测试.

Tested in Jupyter 4.4.0.

这篇关于如何从命令行将Jupyter笔记本导出为HTML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆