LoginSignup
0
1

More than 1 year has passed since last update.

pyinstaller に関するメモ

Last updated at Posted at 2021-06-02

#pyinstaller 起動オプション

pyinstaller xxxx.py --onedir --onefile --noconsole --clean
  • --onedir or -D
    出力を1ディレクトリにまとめる
  • --onefile or -F
    出力を1ファイルにまとめる
  • --noconsole or -w
    コンソールを表示しない
  • --clean
    ビルド前に前回のキャッシュと出力ディレクトリを削除

#pyinstallerで作ったモジュールでUnicodeEncodeErrorが出る対策
###標準出力の場合

import io, sys, logging
# 標準出力をUTF-8に設定
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')

###loggingの場合、ファイルハンドラに「encoding='utf-8'」を追加する。

# ファイル出力用ハンドラ
handler = FileHandler(filename=filename, encoding='utf-8')
handler.setLevel(_logging_level)
handler.setFormatter(Formatter(formatter))
logger.addHandler(handler)
0
1
1

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
1