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?

Colabでjupyter nbconvert実行時にKeyError: 'state'が出たときの解決法

0
Last updated at Posted at 2026-07-13

コード

以下のプログラムはjupyter nbconvertでipynb形式のファイルをhtmlに変換するコードです。

使い方

  1. 以下のプログラムをコピーして、Colabに張り付ける
  2. ファイルをColabにアップロードする
  3. 変数FileNameをアップロードしたファイル名にする
    (例:text.ipynbをアップロードしたら、1行目はFileName = "test.ipynb"になる。)
  4. Colabのコードセルの実行をする
FileName = "○○○○.ipynb"
Directory = "/content/"
Origin = FileName.replace('.ipynb', '')

# Install required package
!apt install jq

# delete metadata widget
!jq -M 'del(.metadata.widgets)' $Directory$FileName > $Directory$FileName"_fiexd.ipynb"

# restore filename
!mv $Directory$FileName"_fiexd.ipynb" $Directory$FileName

# converte to html
!jupyter nbconvert --to html $Directory$FileName

参考

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?