抑制 Jupyter 笔记本中火花输出的最佳方法是什么?
What is the best way to suppress the spark output in the Jupyter notebook?
我最近将 os 从 ubuntu 更改为 mac。(4 年多之后)
让我很烦恼的一件事是。
火花 stdout/stderr 现在打印在笔记本上,而不是只停留在控制台内(就像在我的 ubuntu 上一样)。
我曾尝试禁用 ipython 启动时的警告,但没有成功。
~/.ipython/profile_default/startup/disable-warning.py
import warnings
warnings.filterwarnings('ignore')
另一方面,我不完全确定这是否是 mac 问题。在我的开发环境设置过程中是否出现了愚蠢的错误?
谢谢!
看来是新的jupyter版本导致的。升级我的 jupyter 后我得到了这个输出。我仍然找不到好的方法,但这是我最后的解决方法:
%%html
<style>
div.output_stderr {
display: none;
}
</style>
notebook 输出的修改来自版本 6.0.0
of ipykernel 中所做的更改之一。
All outputs to stdout/stderr should now be captured, including subprocesses and output of compiled libraries (blas, lapack....). In notebook server, some outputs that would previously go to the notebooks logs will now both head to notebook logs and in notebooks outputs.
随后的 fix 提供了一种恢复以前行为的方法。
修复包括通过 capture_fd_output
flag, see this comment 关闭捕获新行为以获取更多详细信息。
您可以通过在 ipython 个人资料中将其关闭来进行配置。
# create a default profile
ipython profile create
# turn off the capture flag
echo "c.IPKernelApp.capture_fd_output = False" >> \
"~/.ipython/profile_default/ipython_kernel_config.py"
就是这样! Java、Spark 和 Ivy 的所有输出将不再显示在笔记本中,而只会显示在日志中。
备注
- 也可以通过将
ipython_kernel_config.py
放入 /etc/ipython/
目录来在系统范围内完成,请参阅 doc 了解更多信息。
- 作为记录,这里是 PR implementing this fix on Jupyter Docker Stacks。
我最近将 os 从 ubuntu 更改为 mac。(4 年多之后)
让我很烦恼的一件事是。 火花 stdout/stderr 现在打印在笔记本上,而不是只停留在控制台内(就像在我的 ubuntu 上一样)。
我曾尝试禁用 ipython 启动时的警告,但没有成功。
~/.ipython/profile_default/startup/disable-warning.py
import warnings
warnings.filterwarnings('ignore')
另一方面,我不完全确定这是否是 mac 问题。在我的开发环境设置过程中是否出现了愚蠢的错误?
谢谢!
看来是新的jupyter版本导致的。升级我的 jupyter 后我得到了这个输出。我仍然找不到好的方法,但这是我最后的解决方法:
%%html
<style>
div.output_stderr {
display: none;
}
</style>
notebook 输出的修改来自版本 6.0.0
of ipykernel 中所做的更改之一。
All outputs to stdout/stderr should now be captured, including subprocesses and output of compiled libraries (blas, lapack....). In notebook server, some outputs that would previously go to the notebooks logs will now both head to notebook logs and in notebooks outputs.
随后的 fix 提供了一种恢复以前行为的方法。
修复包括通过 capture_fd_output
flag, see this comment 关闭捕获新行为以获取更多详细信息。
您可以通过在 ipython 个人资料中将其关闭来进行配置。
# create a default profile
ipython profile create
# turn off the capture flag
echo "c.IPKernelApp.capture_fd_output = False" >> \
"~/.ipython/profile_default/ipython_kernel_config.py"
就是这样! Java、Spark 和 Ivy 的所有输出将不再显示在笔记本中,而只会显示在日志中。
备注
- 也可以通过将
ipython_kernel_config.py
放入/etc/ipython/
目录来在系统范围内完成,请参阅 doc 了解更多信息。 - 作为记录,这里是 PR implementing this fix on Jupyter Docker Stacks。