PythonスクリプトをEXE化する環境をPythonインストールから構築したときの作業ログ

PythonインストールからExe化までググればいっぱい出てくるので、今回は、その時に作業した時のただのログです。

Python 3.8のインストール

以下のURLからPythonをインストール
Add Python 3.xx to Path にチェックを付けてインストールすること

Python Release Python 3.8.2
The official home of the Python Programming Language

pyinstallerをインストール

管理者モードでコマンドプロンプトを開き
pip install pyinstaller
pyinstaller test.py –onefile
でEXE化できる。

作業中pipをアップグレードせよと警告が出たので
python -m pip install –upgrade pip

Microsoft Windows [Version 10.0.18362.720]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\WINDOWS\system32>python
Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> ^Z


C:\WINDOWS\system32>cd \users\pcm_n

C:\Users\pcm_n>pyinstaller
'pyinstaller' は、内部コマンドまたは外部コマンド、
操作可能なプログラムまたはバッチ ファイルとして認識されていません。

C:\Users\pcm_n>pip install pyinstaller
Collecting pyinstaller
  Downloading https://files.pythonhosted.org/packages/3c/c9/c3f9bc64eb11eee6a824686deba6129884c8cbdf70e750661773b9865ee0/PyInstaller-3.6.tar.gz (3.5MB)
     |████████████████████████████████| 3.5MB 2.2MB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting pefile>=2017.8.1 (from pyinstaller)
  Downloading https://files.pythonhosted.org/packages/36/58/acf7f35859d541985f0a6ea3c34baaefbfaee23642cf11e85fe36453ae77/pefile-2019.4.18.tar.gz (62kB)
     |████████████████████████████████| 71kB 4.5MB/s
Collecting altgraph (from pyinstaller)
  Downloading https://files.pythonhosted.org/packages/ee/3d/bfca21174b162f6ce674953f1b7a640c1498357fa6184776029557c25399/altgraph-0.17-py2.py3-none-any.whl
Collecting pywin32-ctypes>=0.2.0 (from pyinstaller)
  Downloading https://files.pythonhosted.org/packages/9e/4b/3ab2720f1fa4b4bc924ef1932b842edf10007e4547ea8157b0b9fc78599a/pywin32_ctypes-0.2.0-py2.py3-none-any.whl
Requirement already satisfied: setuptools in c:\python\python38\lib\site-packages (from pyinstaller) (41.2.0)
Collecting future (from pefile>=2017.8.1->pyinstaller)
  Downloading https://files.pythonhosted.org/packages/45/0b/38b06fd9b92dc2b68d58b75f900e97884c45bedd2ff83203d933cf5851c9/future-0.18.2.tar.gz (829kB)
     |████████████████████████████████| 829kB 6.8MB/s
Building wheels for collected packages: pyinstaller
  Building wheel for pyinstaller (PEP 517) ... done
  Created wheel for pyinstaller: filename=PyInstaller-3.6-cp38-none-any.whl size=2926582 sha256=721becc0a6ebf2e95cdffa74aa49be339523cc908d6ed6eba9188152f4f39dc5
  Stored in directory: C:\Users\pcm_n\AppData\Local\pip\Cache\wheels\62\fe\62\4c0f196d1e0dd689e097449bc81d7d585a7de7dd86b081b80b
Successfully built pyinstaller
Installing collected packages: future, pefile, altgraph, pywin32-ctypes, pyinstaller
  Running setup.py install for future ... done
  Running setup.py install for pefile ... done
Successfully installed altgraph-0.17 future-0.18.2 pefile-2019.4.18 pyinstaller-3.6 pywin32-ctypes-0.2.0
WARNING: You are using pip version 19.2.3, however version 20.0.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

C:\Users\pcm_n>python -m pip install --upgrade pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/54/0c/d01aa759fdc501a58f431eb594a17495f15b88da142ce14b5845662c13f3/pip-20.0.2-py2.py3-none-any.whl (1.4MB)
     |████████████████████████████████| 1.4MB 6.4MB/s
Installing collected packages: pip
  Found existing installation: pip 19.2.3
    Uninstalling pip-19.2.3:
      Successfully uninstalled pip-19.2.3
Successfully installed pip-20.0.2

C:\Users\pcm_n>dir *.py
 ドライブ C のボリューム ラベルがありません。
 ボリューム シリアル番号は FA7A-22F4 です

 C:\Users\pcm_n のディレクトリ

2020/03/23  15:21                18 test.py
               1 個のファイル                  18 バイト
               0 個のディレクトリ   7,030,792,192 バイトの空き領域

C:\Users\pcm_n>type test.py
print("Hello !")

C:\Users\pcm_n>pyinstaller test.py --onefile
152 INFO: PyInstaller: 3.6
152 INFO: Python: 3.8.2
155 INFO: Platform: Windows-10-10.0.18362-SP0
157 INFO: wrote C:\Users\pcm_n\test.spec
161 INFO: UPX is not available.
163 INFO: Extending PYTHONPATH with paths
['C:\\Users\\pcm_n', 'C:\\Users\\pcm_n']
164 INFO: checking Analysis
165 INFO: Building Analysis because Analysis-00.toc is non existent
167 INFO: Initializing module dependency graph...
176 INFO: Caching module graph hooks...
190 INFO: Analyzing base_library.zip ...
4669 INFO: Processing pre-find module path hook   distutils
4672 INFO: distutils: retargeting to non-venv dir 'c:\\python\\python38\\lib'
9274 INFO: Caching module dependency graph...
9536 INFO: running Analysis Analysis-00.toc
9541 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\python\python38\python.exe
10377 INFO: Analyzing C:\Users\pcm_n\test.py
10381 INFO: Processing module hooks...
10381 INFO: Loading module hook "hook-distutils.py"...
10385 INFO: Loading module hook "hook-encodings.py"...
10547 INFO: Loading module hook "hook-lib2to3.py"...
10566 INFO: Loading module hook "hook-pydoc.py"...
10568 INFO: Loading module hook "hook-sysconfig.py"...
10570 INFO: Loading module hook "hook-xml.etree.cElementTree.py"...
10572 INFO: Loading module hook "hook-xml.py"...
10657 INFO: Loading module hook "hook-_tkinter.py"...
11044 INFO: checking Tree
11044 INFO: Building Tree because Tree-00.toc is non existent
11047 INFO: Building Tree Tree-00.toc
11311 INFO: checking Tree
11314 INFO: Building Tree because Tree-01.toc is non existent
11315 INFO: Building Tree Tree-01.toc
11381 INFO: Looking for ctypes DLLs
11445 INFO: Analyzing run-time hooks ...
11452 INFO: Including run-time hook 'pyi_rth__tkinter.py'
11455 INFO: Including run-time hook 'pyi_rth_multiprocessing.py'
11470 INFO: Looking for dynamic libraries
11914 INFO: Looking for eggs
11914 INFO: Using Python library c:\python\python38\python38.dll
11916 INFO: Found binding redirects:
[]
11928 INFO: Warnings written to C:\Users\pcm_n\build\test\warn-test.txt
12023 INFO: Graph cross-reference written to C:\Users\pcm_n\build\test\xref-test.html
12092 INFO: checking PYZ
12093 INFO: Building PYZ because PYZ-00.toc is non existent
12095 INFO: Building PYZ (ZlibArchive) C:\Users\pcm_n\build\test\PYZ-00.pyz
13193 INFO: Building PYZ (ZlibArchive) C:\Users\pcm_n\build\test\PYZ-00.pyz completed successfully.
13211 INFO: checking PKG
13211 INFO: Building PKG because PKG-00.toc is non existent
13212 INFO: Building PKG (CArchive) PKG-00.pkg
19289 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
19334 INFO: Bootloader c:\python\python38\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
19335 INFO: checking EXE
19337 INFO: Building EXE because EXE-00.toc is non existent
19339 INFO: Building EXE from EXE-00.toc
19340 INFO: Appending archive to EXE C:\Users\pcm_n\dist\test.exe
19359 INFO: Building EXE from EXE-00.toc completed successfully.

C:\Users\pcm_n>cd dist

C:\Users\pcm_n\dist>dir
 ドライブ C のボリューム ラベルがありません。
 ボリューム シリアル番号は FA7A-22F4 です

 C:\Users\pcm_n\dist のディレクトリ

2020/03/28  12:14    <DIR>          .
2020/03/28  12:14    <DIR>          ..
2020/03/28  12:14        10,620,130 test.exe
               1 個のファイル          10,620,130 バイト
               2 個のディレクトリ   6,996,328,448 バイトの空き領域

C:\Users\pcm_n\dist>test.exe
Hello !

C:\Users\pcm_n\dist>

Anaconda編

Anacondaをインストール

Page not found | Anaconda

Anaconda Prompt(Anaconda3)を開き、
conda install pyinstaller

あとは同じ。

コメント

タイトルとURLをコピーしました