LoginSignup
1
2

More than 1 year has passed since last update.

cx_Freezeを使ってEXE化

Last updated at Posted at 2021-12-06

1.anaconda promptでcx_Freezeをインストール

pip install cx_Freeze --upgrade

https://tomomai.com/python_cx_freeze/
を参考。

2.setup.pyファイルを作る。アイコンをつけたい場合は,icoファイルを作成する。
  以下,setup.pyファイル。

# coding: utf-8
# cx_Freeze 用セットアップファイル

import sys
from cx_Freeze import setup, Executable

base = None

# GUI=有効, CUI=無効 にする
if sys.platform == 'win32' : base = 'Win32GUI'

# exe にしたい python ファイルを指定
exe = Executable(script = 'MeasureJudge.py',
                 base = base, icon='kabutomusi.ico')

# セットアップ
setup(name = 'Image_Judge',
      version = '0.1',
      description = 'Image_Judge',
      executables = [exe])

3.setup.py と exe化したい Pythonファイル(MeasureJudge.py)を所定の同じフォルダに入れる。アイコンをつけたい場合は,同じフォルダに入れる。

4.anaconda promptでsetup.pyがあるフォルダまで移動して
(移動は,cd コマンドを使う。場所確認は dir コマンド。)

python setup.py build

を実行する。新しくフォルダが作成され,exeファイルとlibフォルダが作成されている。

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