0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

nbconvert覚え書き

Last updated at Posted at 2020-07-10

convert時に、特定のセルを無視したい

nbconvertで、タグを無視させることができる。

jupyter notebookのテンプレートにtex (pdf) 用のプリアンブルと、html用のプリアンブルの両方を用意しておき、nbconvert時にいらない方のセルを無視させればよい。

そもそもタグって何

左上のメニューで、View -> Cell Toolbar -> Tags を選ぶと、各セルにタグをつけられるようになる。

タグの無視設定

TagRemovePreprocessor.remove_input_tags
TagRemovePreprocessor.remove_single_output_tags
TagRemovePreprocessor.remove_all_outputs_tags

忘れるので、以下を設定。

~/.bashrc
juphtml ()
{
   \jupyter nbconvert  --to html --execute "$@" --TagRemovePreprocessor.remove_cell_tags="{'tex'}"
}
juppdf ()
{
   \jupyter nbconvert --to pdf --execute "$@" --TagRemovePreprocessor.remove_cell_tags="{'html'}"

タイムアウトを回避

10分(600秒)に設定する場合。

jupyter nbconvert --ExecutePreprocessor.timeout=600 
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?