勉強しないとな~blog

ちゃんと勉強せねば…な電気設計エンジニアです。

OpenCVやってみる - 53. Pyinstallerでexe化

予定通り、春のパン祭り点数集計アプリのexe化をやってみます。

今回は基本的にはJupyterを使わない記事です。

スクリプト更新

今まで、tkinterを使ったGUIはJupyter上で試していただけなので、スクリプトに追加します。

スクリプトは、GitHubに上げました。
今までprivateリポジトリとして用意していましたが、今回ライセンスファイル(MITライセンス)も追加したうえでpublicにしてみました。

よかったらご覧ください。

GitHub - hubnoki/harupan: 春のパン祭り自動計算

以下は実行結果。コマンドプロンプトからの実行です。

(py37cv2) C:\work\OpenCV\harupan\harupan_data>python harupan.py
Canvas size: 490,314
Number of threads: 4
   <_MainThread(MainThread, started 27100)>
   <Thread(thread1, started 3120)>
   <Thread(thread2, started 17288)>
   <Thread(thread3, started 25248)>
Camera opened
Camera closed
Number of threads: 1
   <_MainThread(MainThread, started 27100)>

(py37cv2) C:\work\OpenCV\harupan\harupan_data>

結果は当然特に変わらず。

exe化

Pythonスクリプトをexe化する方法はいくつかあるようでした。

PyInstallerでPythonをexe化!ライブラリの比較、注意点も解説 | プログラミングを学ぶならトレノキャンプ(TRAINOCAMP)

Pyinstallerが標準的ぽいのでこれを使いたいですが、Nuitkaというのを見ると、実行ファイルの実行速度が速くなることがある、ということで、こちらも試してみたいと思います。

処理時間表示

コードに点数計算の処理時間を出すようにしておきました。

↓ 処理時間表示用のLabel追加

#### Calculation time ####
self.t_calc_time = tk.StringVar(value='     ms')
self.label_calc_time = tk.Label(self.frame_result, font=('Consolas', 10), textvariable=self.t_calc_time)
...
self.label_calc_time.grid(row=0, column=2, padx=(5,0))

↓ 処理時間計測

t = time.time()
score, img2 = calc_harupan(img, self.templates, self.svm)
t = time.time() - t
if not self.q_img2.full():
    self.t_calc_result.set(f'{score:2.1f} points')
    self.t_calc_time.set(f'{int(t*1000):4d} ms')

処理時間は出せました。
かなり遅いことが分かります。3秒近くかかっています。

conda環境再作成

続いてPyinstallerでのexe化を実施ですが、実際にやってみたところうまくいかず、
condaの環境を作り直しました。

結果的に、うまくいかなかったのはデータファイルの指定をしていなかったからでしたが、 環境を作り直して最小限のパッケージだけ含めることで、実行ファイルのサイズがだいぶ小さくなりました。

↓ conda環境作成

(py37cv2) C:\work\OpenCV\harupan\harupan_data>conda create -n harupan python=3.7
Collecting package metadata (current_repodata.json): done
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.8.2
  latest version: 23.3.1

Please update conda by running

    $ conda update -n base -c defaults conda



## Package Plan ##

  environment location: C:\Users\a\anaconda3\envs\harupan

  added / updated specs:
    - python=3.7


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    ca-certificates-2023.01.10 |       haa95532_0         121 KB
    certifi-2022.12.7          |   py37haa95532_0         149 KB
    openssl-1.1.1t             |       h2bbff1b_0         5.5 MB
    pip-22.3.1                 |   py37haa95532_0         2.7 MB
    python-3.7.16              |       h6244533_0        17.2 MB
    setuptools-65.6.3          |   py37haa95532_0         1.1 MB
    sqlite-3.41.1              |       h2bbff1b_0         897 KB
    vc-14.2                    |       h21ff451_1           8 KB
    vs2015_runtime-14.27.29016 |       h5e58377_2        1007 KB
    wheel-0.38.4               |   py37haa95532_0          82 KB
    wincertstore-0.2           |   py37haa95532_2          15 KB
    ------------------------------------------------------------
                                           Total:        28.8 MB

The following NEW packages will be INSTALLED:

  ca-certificates    pkgs/main/win-64::ca-certificates-2023.01.10-haa95532_0
  certifi            pkgs/main/win-64::certifi-2022.12.7-py37haa95532_0
  openssl            pkgs/main/win-64::openssl-1.1.1t-h2bbff1b_0
  pip                pkgs/main/win-64::pip-22.3.1-py37haa95532_0
  python             pkgs/main/win-64::python-3.7.16-h6244533_0
  setuptools         pkgs/main/win-64::setuptools-65.6.3-py37haa95532_0
  sqlite             pkgs/main/win-64::sqlite-3.41.1-h2bbff1b_0
  vc                 pkgs/main/win-64::vc-14.2-h21ff451_1
  vs2015_runtime     pkgs/main/win-64::vs2015_runtime-14.27.29016-h5e58377_2
  wheel              pkgs/main/win-64::wheel-0.38.4-py37haa95532_0
  wincertstore       pkgs/main/win-64::wincertstore-0.2-py37haa95532_2


Proceed ([y]/n)?


Downloading and Extracting Packages
wincertstore-0.2     | 15 KB     | ################################################################################## | 100%  
pip-22.3.1           | 2.7 MB    | ################################################################################## | 100%  
openssl-1.1.1t       | 5.5 MB    | ################################################################################## | 100%  
sqlite-3.41.1        | 897 KB    | ################################################################################## | 100%  
ca-certificates-2023 | 121 KB    | ################################################################################## | 100%  
certifi-2022.12.7    | 149 KB    | ################################################################################## | 100%  
python-3.7.16        | 17.2 MB   | ################################################################################## | 100%  
vs2015_runtime-14.27 | 1007 KB   | ################################################################################## | 100%  
vc-14.2              | 8 KB      | ################################################################################## | 100%  
wheel-0.38.4         | 82 KB     | ################################################################################## | 100%  
setuptools-65.6.3    | 1.1 MB    | ################################################################################## | 100%  
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate harupan
#
# To deactivate an active environment, use
#
#     $ conda deactivate


(py37cv2) C:\work\OpenCV\harupan\harupan_data>conda activate harupan

(harupan) C:\work\OpenCV\harupan\harupan_data>conda list
# packages in environment at C:\Users\a\anaconda3\envs\harupan:
#
# Name                    Version                   Build  Channel
ca-certificates           2023.01.10           haa95532_0
certifi                   2022.12.7        py37haa95532_0
openssl                   1.1.1t               h2bbff1b_0
pip                       22.3.1           py37haa95532_0
python                    3.7.16               h6244533_0
setuptools                65.6.3           py37haa95532_0
sqlite                    3.41.1               h2bbff1b_0
vc                        14.2                 h21ff451_1
vs2015_runtime            14.27.29016          h5e58377_2
wheel                     0.38.4           py37haa95532_0
wincertstore              0.2              py37haa95532_2

↓ 必要なパッケージインストール(opencv-python, Pillow)

(harupan) C:\work\OpenCV\harupan\harupan_data>pip install opencv-python
Collecting opencv-python
  Using cached opencv_python-4.7.0.72-cp37-abi3-win_amd64.whl (38.2 MB)
Collecting numpy>=1.17.0
  Downloading numpy-1.21.6-cp37-cp37m-win_amd64.whl (14.0 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 14.0/14.0 MB 5.5 MB/s eta 0:00:00
Installing collected packages: numpy, opencv-python
Successfully installed numpy-1.21.6 opencv-python-4.7.0.72

(harupan) C:\work\OpenCV\harupan\harupan_data>pip install Pillow
Collecting Pillow
  Downloading Pillow-9.5.0-cp37-cp37m-win_amd64.whl (2.5 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.5/2.5 MB 5.8 MB/s eta 0:00:00
Installing collected packages: Pillow
Successfully installed Pillow-9.5.0

Pythonスクリプト動作確認

(harupan) C:\work\OpenCV\harupan\harupan_data>python harupan.py  
Canvas size: 490,314
Number of threads: 4
   <_MainThread(MainThread, started 29612)>
   <Thread(thread1, started 28132)>
   <Thread(thread2, started 6116)>
   <Thread(thread3, started 19860)>
Camera opened
harupan.py:257: DeprecationWarning: `np.float` is a deprecated alias for the builtin `float`. To silence this warning, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations     
  return 1.0 - np.float(np.count_nonzero(xor_img)) / (img1.shape[0]*img2.shape[1])
Camera closed
Number of threads: 1
   <_MainThread(MainThread, started 29612)>

↓ Pyinstallerインストール

(harupan) C:\work\OpenCV\harupan\harupan_data>pip install pyinstaller
Collecting pyinstaller
  Downloading pyinstaller-5.10.0-py3-none-win_amd64.whl (1.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.3/1.3 MB 5.4 MB/s eta 0:00:00
Collecting pefile>=2022.5.30
  Using cached pefile-2023.2.7-py3-none-any.whl (71 kB)
Collecting importlib-metadata>=1.4
  Downloading importlib_metadata-6.3.0-py3-none-any.whl (22 kB)
Collecting altgraph
  Using cached altgraph-0.17.3-py2.py3-none-any.whl (21 kB)
Collecting pywin32-ctypes>=0.2.0
  Downloading pywin32_ctypes-0.2.0-py2.py3-none-any.whl (28 kB)
Collecting pyinstaller-hooks-contrib>=2021.4
  Using cached pyinstaller_hooks_contrib-2023.2-py2.py3-none-any.whl (261 kB)
Requirement already satisfied: setuptools>=42.0.0 in c:\users\a\anaconda3\envs\harupan\lib\site-packages (from pyinstaller) (65.6.3)
Collecting zipp>=0.5
  Downloading zipp-3.15.0-py3-none-any.whl (6.8 kB)
Collecting typing-extensions>=3.6.4
  Downloading typing_extensions-4.5.0-py3-none-any.whl (27 kB)
Installing collected packages: pywin32-ctypes, altgraph, zipp, typing-extensions, pyinstaller-hooks-contrib, pefile, importlib-metadata, pyinstaller
Successfully installed altgraph-0.17.3 importlib-metadata-6.3.0 pefile-2023.2.7 pyinstaller-5.10.0 pyinstaller-hooks-contrib-2023.2 pywin32-ctypes-0.2.0 typing-extensions-4.5.0 zipp-3.15.0

(harupan) C:\work\OpenCV\harupan\harupan_data>pip list
Package                   Version
------------------------- ---------
altgraph                  0.17.3
certifi                   2022.12.7
importlib-metadata        6.3.0
numpy                     1.21.6
opencv-python             4.7.0.72
pefile                    2023.2.7
Pillow                    9.5.0
pip                       22.3.1
pyinstaller               5.10.0
pyinstaller-hooks-contrib 2023.2
pywin32-ctypes            0.2.0
setuptools                65.6.3
typing_extensions         4.5.0
wheel                     0.38.4
wincertstore              0.2
zipp                      3.15.0

(harupan) C:\work\OpenCV\harupan\harupan_data>

Pyinstallerでexe化

今回のアプリは、SVMと点数文字テンプレートのデータファイルを使っています。
そのため、以下の変更等が必要でした。

  • Pyinstaller実行時に--add-dataオプションでデータファイルを指定 → exe生成時にデータファイルがコピーされる
  • データファイルをexeと同じパスの下に置くことができなかったので、dataフォルダを作ってその中に配置、対応してPythonスクリプトを変更

変更内容

  • ファイル配置変更
(アプリルート)  
├─ harupan.py  
├─ harupan_svm_220412.dat  
├─ templates2021.json

(アプリルート)  
├─ harupan.py  
├─ data  
│   ├─ harupan_svm_220412.dat  
│   └─ templates2021.json
...
    svm_data='harupan_svm_220412.dat'
    template_data='templates2021.json'
...

...
    svm_data='data/harupan_svm_220412.dat'
    template_data='data/templates2021.json'
...

Pyinstaller実行

Pyinstallerは以下のようにコマンドプロンプトから実行。
Windows形式のパスでの記述になります。

--add-dataオプションの使い方は以下参照。

Windowsでは、

データファイルのパス;exeでの配置ディレクトリ(exeファイルからの相対パス)

の形で指定します。

【超簡単】Python プログラムを pyinstaller で EXE化しよう | 趣味や仕事に役立つ初心者DIYプログラミング入門

Python pyinstallerで実行ファイル化(exe化) - IT技術で仕事を減らしたい!

pyinstaller harupan.py --add-data data\harupan_svm_220412.dat;data --add-data data\templates2021.json;data

実行結果。とりあえず全部載せちゃいます。長くなりますがご容赦。

(harupan) C:\work\OpenCV\harupan\harupan_data>pyinstaller harupan.py --add-data data\harupan_svm_220412.dat;data --add-data data\templates2021.json;data                           
588 INFO: PyInstaller: 5.10.0
588 INFO: Python: 3.7.16 (conda)
588 INFO: Platform: Windows-10-10.0.22621-SP0
590 INFO: wrote C:\work\OpenCV\harupan\harupan_data\harupan.spec
594 INFO: UPX is not available.
603 INFO: Extending PYTHONPATH with paths
['C:\\Users\\a\\work\\OpenCV\\harupan\\harupan_data']
939 INFO: Appending 'datas' from .spec
940 INFO: checking Analysis
940 INFO: Building Analysis because Analysis-00.toc is non existent
941 INFO: Initializing module dependency graph...
944 INFO: Caching module graph hooks...
970 INFO: Analyzing base_library.zip ...
3186 INFO: Loading module hook 'hook-heapq.py' from 'C:\\Users\\a\\anaconda3\\envs\\harupan\\lib\\site-packages\\PyInstaller\\hooks'...
3285 INFO: Loading module hook 'hook-encodings.py' from 'C:\\Users\\a\\anaconda3\\envs\\harupan\\lib\\site-packages\\PyInstaller\\hooks'...
4229 INFO: Loading module hook 'hook-pickle.py' from 'C:\\Users\\a\\anaconda3\\envs\\harupan\\lib\\site-packages\\PyInstaller\\hooks'...
5813 INFO: Caching module dependency graph...
5967 INFO: running Analysis Analysis-00.toc
5974 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by C:\Users\a\anaconda3\envs\harupan\python.exe
6283 INFO: Analyzing C:\work\OpenCV\harupan\harupan_data\harupan.py
6323 INFO: Loading module hook 'hook-cv2.py' from 'C:\\Users\\a\\anaconda3\\envs\\harupan\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
7411 INFO: Loading module hook 'hook-numpy.py' from 'C:\\Users\\a\\anaconda3\\envs\\harupan\\lib\\site-packages\\PyInstaller\\hooks'...
7514 WARNING: Conda distribution 'numpy', dependency of 'numpy', was not found. If you installed this distribution with pip then you may ignore this warning.
8097 INFO: Loading module hook 'hook-difflib.py' from 'C:\\Users\\a\\anaconda3\\envs\\harupan\\lib\\site-packages\\PyInstaller\\hooks'...
8215 INFO: Loading module hook 'hook-platform.py' from 'C:\\Users\\a\\anaconda3\\envs\\harupan\\lib\\site-packages\\PyInstaller\\hooks'...
8476 INFO: Loading module hook 'hook-sysconfig.py' from 'C:\\Users\\a\\anaconda3\\envs\\harupan\\lib\\site-packages\\PyInstaller\\hooks'...
9666 INFO: Loading module hook 'hook-PIL.py' from 'C:\\Users\\a\\anaconda3\\envs\\harupan\\lib\\site-packages\\PyInstaller\\hooks'...
9740 INFO: Loading module hook 'hook-PIL.Image.py' from 'C:\\Users\\a\\anaconda3\\envs\\harupan\\lib\\site-packages\\PyInstaller\\hooks'...
10829 INFO: Loading module hook 'hook-PIL.ImageFilter.py' from 'C:\\Users\\a\\anaconda3\\envs\\harupan\\lib\\site-packages\\PyInstaller\\hooks'...
10887 INFO: Processing module hooks...
10966 WARNING: Hidden import "six" not found!
11201 INFO: Loading module hook 'hook-PIL.SpiderImagePlugin.py' from 'C:\\Users\\a\\anaconda3\\envs\\harupan\\lib\\site-packages\\PyInstaller\\hooks'...
11243 INFO: Loading module hook 'hook-_tkinter.py' from 'C:\\Users\\a\\anaconda3\\envs\\harupan\\lib\\site-packages\\PyInstaller\\hooks'...
11245 INFO: checking Tree
11245 INFO: Building Tree because Tree-00.toc is non existent
11245 INFO: Building Tree Tree-00.toc
11302 INFO: checking Tree
11303 INFO: Building Tree because Tree-01.toc is non existent
11303 INFO: Building Tree Tree-01.toc
11310 INFO: checking Tree
11310 INFO: Building Tree because Tree-02.toc is non existent
11311 INFO: Building Tree Tree-02.toc
11342 INFO: Looking for ctypes DLLs
11348 INFO: Analyzing run-time hooks ...
11352 INFO: Including run-time hook 'C:\\Users\\a\\anaconda3\\envs\\harupan\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth__tkinter.py'
11356 INFO: Including run-time hook 'C:\\Users\\a\\anaconda3\\envs\\harupan\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgutil.py'
11360 INFO: Including run-time hook 'C:\\Users\\a\\anaconda3\\envs\\harupan\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_inspect.py'
11388 INFO: Looking for dynamic libraries
13132 INFO: Looking for eggs
13132 INFO: Using Python library C:\Users\a\anaconda3\envs\harupan\python37.dll
13133 INFO: Found binding redirects:
[]
13142 INFO: Warnings written to C:\work\OpenCV\harupan\harupan_data\build\harupan\warn-harupan.txt
13208 INFO: Graph cross-reference written to C:\work\OpenCV\harupan\harupan_data\build\harupan\xref-harupan.html
13279 INFO: checking PYZ
13280 INFO: Building PYZ because PYZ-00.toc is non existent
13280 INFO: Building PYZ (ZlibArchive) C:\work\OpenCV\harupan\harupan_data\build\harupan\PYZ-00.pyz
13940 INFO: Building PYZ (ZlibArchive) C:\work\OpenCV\harupan\harupan_data\build\harupan\PYZ-00.pyz completed successfully.
13954 INFO: checking PKG
13955 INFO: Building PKG because PKG-00.toc is non existent
13955 INFO: Building PKG (CArchive) harupan.pkg
13988 INFO: Building PKG (CArchive) harupan.pkg completed successfully.
13990 INFO: Bootloader C:\Users\a\anaconda3\envs\harupan\lib\site-packages\PyInstaller\bootloader\Windows-64bit-intel\run.exe
13991 INFO: checking EXE
13991 INFO: Building EXE because EXE-00.toc is non existent
13991 INFO: Building EXE from EXE-00.toc
13992 INFO: Copying bootloader EXE to C:\work\OpenCV\harupan\harupan_data\build\harupan\harupan.exe.notanexecutable
14044 INFO: Copying icon to EXE
14046 INFO: Copying icons from ['C:\\Users\\a\\anaconda3\\envs\\harupan\\lib\\site-packages\\PyInstaller\\bootloader\\images\\icon-console.ico']
14079 INFO: Writing RT_GROUP_ICON 0 resource with 104 bytes
14080 INFO: Writing RT_ICON 1 resource with 3752 bytes
14080 INFO: Writing RT_ICON 2 resource with 2216 bytes
14080 INFO: Writing RT_ICON 3 resource with 1384 bytes
14081 INFO: Writing RT_ICON 4 resource with 37019 bytes
14081 INFO: Writing RT_ICON 5 resource with 9640 bytes
14081 INFO: Writing RT_ICON 6 resource with 4264 bytes
14082 INFO: Writing RT_ICON 7 resource with 1128 bytes
14087 INFO: Copying 0 resources to EXE
14087 INFO: Embedding manifest in EXE
14088 INFO: Updating manifest in C:\work\OpenCV\harupan\harupan_data\build\harupan\harupan.exe.notanexecutable
14120 INFO: Updating resource type 24 name 1 language 0
14124 INFO: Appending PKG archive to EXE
14132 INFO: Fixing EXE headers
14293 INFO: Building EXE from EXE-00.toc completed successfully.
14298 INFO: checking COLLECT
14299 INFO: Building COLLECT because COLLECT-00.toc is non existent
14299 INFO: Building COLLECT COLLECT-00.toc
17707 INFO: Building COLLECT COLLECT-00.toc completed successfully.

(harupan) C:\work\OpenCV\harupan\harupan_data>

以下のように生成物ができました。
distフォルダ内のhaupan.exeをダブルクリックすると、アプリが起動しました。
コマンドプロンプトも一緒に起動していて、print()でのコンソール出力が表示されています。

(アプリルート)  
├─ build
│   └─ harupan
│        └─ 中間生成物色々
└─ dist
     └─ harupan    ... フォルダサイズ 157MB !
          ├─ harupan.exe
          ├─ data
          │   ├─ harupan_svm_220412.dat  
          │   └─ templates2021.json
          └─ その他exe実行に必要なファイル、フォルダ

その他オプション指定

  • --noconsoleで、コマンドプロンプト起動なしにする
  • --onefileで1つのexeファイルにまとめる
    ただし、今回はデータファイルも含むので、下記に記載のような対応が必要。

PyInstallerで実行ファイルにリソースを埋め込み - Qiita

######################################################
# main
######################################################
def resource_path(relative_path):
    if hasattr(sys, '_MEIPASS'):
        return os.path.join(sys._MEIPASS, relative_path)
    return os.path.join(os.path.abspath("."), relative_path)

def main():
    root = tk.Tk()
    svm_data = resource_path('data/harupan_svm_220412.dat')
    template_data = resource_path('data/templates2021.json')
    app = harupan_gui(master=root, img_queue_size=1, svm_data=svm_data, template_data=template_data)
    app.mainloop()

Pyinstaller実行結果。
前の生成結果を残すために、--distpathオプションで出力先をdist2に変更しています。

(harupan) C:\work\OpenCV\harupan\harupan_data>pyinstaller harupan.py --add-data data\harupan_svm_220412.dat;data --add-data data\templates2021.json;data --noconsole --onefile --distpath dist2 
1414 INFO: PyInstaller: 5.10.0
1415 INFO: Python: 3.7.16 (conda)
1416 INFO: Platform: Windows-10-10.0.22621-SP0
1418 INFO: wrote C:\work\OpenCV\harupan\harupan_data\harupan.spec
1426 INFO: UPX is not available.
1443 INFO: Extending PYTHONPATH with paths
['C:\\Users\\a\\work\\OpenCV\\harupan\\harupan_data']
2211 INFO: Appending 'datas' from .spec
2212 INFO: checking Analysis
2365 INFO: checking PYZ
2406 INFO: checking PKG
2411 INFO: Building because toc changed
2412 INFO: Building PKG (CArchive) harupan.pkg
23543 INFO: Building PKG (CArchive) harupan.pkg completed successfully.
23572 INFO: Bootloader C:\Users\a\anaconda3\envs\harupan\lib\site-packages\PyInstaller\bootloader\Windows-64bit-intel\runw.exe
23572 INFO: checking EXE
23585 INFO: Rebuilding EXE-00.toc because harupan.exe missing
23585 INFO: Building EXE from EXE-00.toc
23586 INFO: Copying bootloader EXE to C:\work\OpenCV\harupan\harupan_data\dist2\harupan.exe.notanexecutable       
23634 INFO: Copying icon to EXE
23637 INFO: Copying icons from ['C:\\Users\\a\\anaconda3\\envs\\harupan\\lib\\site-packages\\PyInstaller\\bootloader\\images\\icon-windowed.ico']
23670 INFO: Writing RT_GROUP_ICON 0 resource with 104 bytes
23670 INFO: Writing RT_ICON 1 resource with 3752 bytes
23670 INFO: Writing RT_ICON 2 resource with 2216 bytes
23670 INFO: Writing RT_ICON 3 resource with 1384 bytes
23670 INFO: Writing RT_ICON 4 resource with 38188 bytes
23671 INFO: Writing RT_ICON 5 resource with 9640 bytes
23671 INFO: Writing RT_ICON 6 resource with 4264 bytes
23671 INFO: Writing RT_ICON 7 resource with 1128 bytes
23675 INFO: Copying 0 resources to EXE
23675 INFO: Embedding manifest in EXE
23677 INFO: Updating manifest in C:\work\OpenCV\harupan\harupan_data\dist2\harupan.exe.notanexecutable
23714 INFO: Updating resource type 24 name 1 language 0
23720 INFO: Appending PKG archive to EXE
23779 INFO: Fixing EXE headers
24343 INFO: Building EXE from EXE-00.toc completed successfully.

(harupan) C:\work\OpenCV\harupan\harupan_data>
(アプリルート)  
└─ dist2
     └─ harupan    ... フォルダサイズ 56.7MB
          └─ harupan.exe

生成物がexeファイルだけになりました。
また、全体のデータサイズも小さくなりました。

ただ、exeをダブルクリックした後実際に起動するまでが少し長くなりました。
圧縮ファイルを展開したりで時間がかかるのか?

処理時間再確認

作ったexeで、実際に点数計算処理をやってみました。

が、特にexe化したからといって処理が速くなったりはしませんでした。

ここまで

今回はここまでにします。

次回は、Nuitkaでのexe化をやってみたいと思います。