nbconvert从命令行输出结果执行Jupyter笔记本 [英] nbconvert Execute Jupyter notebook from Command Line output results

查看:1014
本文介绍了nbconvert从命令行输出结果执行Jupyter笔记本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

必须先问过这个问题,但我找不到正确的答案.我想从命令行运行Jupyter笔记本并将结果保存到某些文件.

This question must've been asked before, but I couldn't find a right answer. I would like to run the Jupyter notebook from command line and save the result to certain files.

我正在运行,

jupyter nbconvert --to python --execute mynotebook.ipynb >> mylog.out.log 2>&1

此命令可以正确执行mynotebook.ipynb,但在日志文件中,如果执行成功,则仅包含3行.

This command executes mynotebook.ipynb properly, but in the log file, it only contains 3 lines if the execution is successful.

[NbConvertApp] Converting notebook mynotebook.ipynb to python
[NbConvertApp] Executing notebook with kernel: python2
[NbConvertApp] Writing 1931 bytes to mynotebook.ipynb.py

如果笔记本计算机引发某些异常,它也会在日志文件中显示该异常.但是我在哪里可以看到笔记本的结果?

If the notebook raises some exception, it will show the exception in the log file too. But where do I see the results of the notebook?

例如,在我的笔记本中,

For example, in my notebook, I have

print 'hello world'

此输出未在我的命令行界面或日志文件中显示.是否有一种方法或参数设置可将输出保存到日志文件中?我想查看mynotebook.ipynb的详细结果.

This output doesn't show in my command line interface or in the log file. Is there an approach or a parameter setting to keep the output into a log file? I would like to see the detailed results of mynotebook.ipynb.

有什么想法吗?还是比 jupyter nbconvert 更好的方法?

Any thought? or any other better method than jupyter nbconvert?

还可以在日志文件中包含日期时间吗?包括时间将是非常有帮助的.

Also, it that possiable to include the datetime into the log file? it would be very helpful to have the time included.

推荐答案

您可以尝试--stdout,并且必须转换为类似html的格式才能查看输出,例如

You can try --stdout and you have to convert to something like html to see output for example

jupyter nbconvert --to html mynotebook.ipynb --stdout --ExecutePreprocessor.kernel_name=python --ExecutePreprocessor.enabled=True

这篇关于nbconvert从命令行输出结果执行Jupyter笔记本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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