简体   繁体   English

如何从命令行将Jupyter笔记本导出为HTML?

[英]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.

相关问题 csv 从命令行执行 jupyter notebook 时导出失败 - csv export failing when executing jupyter notebook from command line 如何从命令行中断 Jupyter 笔记本 - How to interupt a Jupyter notebook from the command line 如何使用代码单元中的行号将 Jupyter Notebook 导出到 html - How to export Jupyter Notebook to html with line numbers in code cells 使用行号将 Jupyter 笔记本导出为 HTML? - Export Jupyter notebook to HTML with line numbers? 如何帮助 Python 找到 Jupyter 命令“jupyter-nbconvert”,将 Jupyter Notebook 导出为 HTML? - How do I help Python find Jupyter command 'jupyter-nbconvert', to export Jupyter Notebook to HTML? 如何在 Jupyter 上以 HTML 格式导出当前笔记本 - How to export current notebook in HTML on Jupyter 在命令行中执行Jupyter Notebook - Executing Jupyter notebook in command line 如何使用 Python 从 Jupyter Notebook 将 Plotly 生成的交互式图形导出为 HTML 文件? - How to export Plotly-generated interactive graph as HTML file from Jupyter Notebook using Python? 如何使用 TOC 和可折叠标题导出独立 (HTML) Jupyter 笔记本 - How to export standalone (HTML) Jupyter notebook with TOC and collapsible headers Jupyter Notebooks:如何将笔记本导出为 HTML,包括 splitcell 扩展? - Jupyter Notebooks: How to export a notebook to HTML including the splitcell extension?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM