LoginSignup
1
1

More than 1 year has passed since last update.

「Pythonで学ぶ音声認識」第3章1節の02prepare_label.pyでUnicodeEncodeErrorになった

Last updated at Posted at 2022-11-22

『Pythonで学ぶ音声認識』のGitHubリポジトリ

環境

windows10 64bit
python3.10

やったこと

pythonでyamlファイルをopen()しようとした。

02prepare_label.py
with open(original_label, mode='r') as yamlfile:

エラー内容

UnicodeDecodeError: 'cp932' codec can't decode byte 0x83 in position 38: illegal multibyte sequence

windowsのコマンドプロンプトで使用される文字コードがShift-jisであり、ファイルのutf-8と整合性が取れないことが原因。

解決策

open()encoding="utf-8"を指定。
他の行のopen()も同様に指定する。

02prepare_label.py
with open(original_label, mode='r', encoding="utf-8") as yamlfile:

参考

1
1
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
1
1