質問編集履歴

1 コマンドを実行した際のメッセージを追加しました。

nyumonsya

nyumonsya score 34

2020/07/12 22:41  投稿

.pyファイルのアプリ化について
お助け頂きたいですm(_ _)m
「**pyinstaller**」を使って、「**.pyファイル**」をアプリ化したいのですが、以下の通り上手くいきません。
「**build**」と「**dist**」のフォルダはちゃんと作成されますが、「**dist**」フォルダの中にあるはずの「**.app**」ファイルも何も無く、空っぽです。
何が問題なのか、アプリ化(**.appファイル**の作成)の方法をご教示頂きたく、何卒、よろしくお願い致します・・!
**【コマンドプロンプトで以下を入力】**
```ここに言語を入力
pyinstaller .pyファイル名 --onefile
```
**【アプリ化したい.pyファイル】**
```ここに言語を入力
#-*- encoding: utf-8 -*-
import tkinter as tk
import tkinter.ttk as ttk
import random
from tkinter import PhotoImage
from tkinter import *
from PIL import ImageOps
from PIL import Image, ImageTk
def kuji():
   list_kuji = ['A賞', 'B賞', 'C賞']
   result = random.choice(list_kuji)
   response_area.configure(text=result)
   
def run():
   global response_area
   root = tk.Tk()
   root.title('くじ')
   canvas = tk.Canvas(width = 60, height = 60)
   canvas.pack()
   image = Image.open('kuji.png')
   photo = ImageTk.PhotoImage(image, master=root)
   Label(root, image = photo).place(x=155, y=170)
   response_area = tk.Label(
       width=15,
       height=2,
       relief="groove")
   response_area.place(x=20, y=20)
   
   button = tk.Button(
       text='  くじを引く  ',
       command=kuji)
   button.place(x=200, y=730)#pack()
   def fix():
       a = root.winfo_geometry().split('+')[0]
       b = a.split('x')
       w = int(b[0])
       h = int(b[1])
       root.geometry('900x900') #('%dx%d' % (w+1, h+1))
   root.update()
   root.after(0, fix)
   root.mainloop()
if __name__ == '__main__':
   run()
   
       
   run()     
```
**【コマンドを実行した際のメッセージ】**  
※文字数制限のため、一部省略しています  
```  
c:\python>pyinstaller 19b_kuji.py --onefile  
1262 INFO: PyInstaller: 3.3.1  
1263 INFO: Python: 3.7.3  
1263 INFO: Platform: Windows-10-10.0.17134-SP0  
1266 INFO: wrote c:\python\19b_kuji.spec  
1268 INFO: UPX is not available.  
1270 INFO: Extending PYTHONPATH with paths  
['c:\\', 'c:\\python']  
1270 INFO: checking Analysis  
1271 INFO: Building Analysis because out00-Analysis.toc is non existent  
1271 INFO: Initializing module dependency graph...  
1290 INFO: Initializing module graph hooks...  
1294 INFO: Analyzing base_library.zip ...  
10415 INFO: running Analysis out00-Analysis.toc  
10423 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable  
 required by c:\users\ユーザ名\appdata\local\programs\python\python37\python.exe  
10622 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\ユーザ名\appdata\local\programs\python\python37\python.exe  
10842 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\ユーザ名\appdata\local\programs\python\python37\python.exe  
11927 WARNING: lib not found: api-ms-win-crt-conio-l1-1-0.dll dependency of c:\users\ユーザ名\appdata\local\programs\python\python37\python37.dll  
13991 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of c:\users\ユーザ名\appdata\local\programs\python\python37\python37.dll  
14830 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of c:\users\ユーザ名\appdata\local\programs\python\python37\VCRUNTIME140.dll  
15051 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\ユーザ名\appdata\local\programs\python\python37\VCRUNTIME140.dll  
15054 INFO: Caching module hooks...  
15063 INFO: Analyzing c:\python\19b_kuji.py  
18822 INFO: Processing pre-find module path hook  distutils  
25285 INFO: Processing pre-find module path hook  site  
25292 INFO: site: retargeting to fake-dir 'c:\\users\\ユーザ名\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\PyInstaller\\fake-modules'  
39907 INFO: Processing pre-safe import module hook  win32com  
63629 INFO: Loading module hooks...  
63629 INFO: Loading module hook "hook-Crypto.py"...  
64812 INFO: Loading module hook "hook-PIL.py"...  
64814 INFO: Excluding import 'tkinter'  
64816 INFO:  Removing import of tkinter from module PIL.ImageTk  
64817 INFO: Import to be excluded not found: 'FixTk'  
64831 INFO: Excluding import 'tkinter'  
64833 INFO: Loading module hook "hook-pkg_resources.py"...  
Traceback (most recent call last):  
 File "<string>", line 41, in <module>  
 File "<string>", line 20, in walk_packages  
 File "c:\python\pkg_resources.py", line 1518, in <module>  
   register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)  
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'  
65162 WARNING: Hidden import "pkg_resources._vendor.appdirs" not found!  
65162 WARNING: Hidden import "pkg_resources._vendor.packaging" not found!  
65163 WARNING: Hidden import "pkg_resources._vendor" not found!  
65163 INFO: Loading module hook "hook-pycparser.py"...  
65165 INFO: Loading module hook "hook-pydoc.py"...  
65167 INFO: Loading module hook "hook-pythoncom.py"...  
Traceback (most recent call last):  
 File "<string>", line 2, in <module>  
 File "c:\users\ユーザ名\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\__init__.py", line 65, in <module>  
   import pkg_resources  
 File "c:\python\pkg_resources.py", line 1518, in <module>  
   register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)  
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'  
76514 INFO: Loading module hook "hook-pywintypes.py"...  
91168 INFO: Loading module hook "hook-_tkinter.py"...  
91450 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\ユーザ名\appdata\local\programs\python\python37\DLLs\_tkinter.pyd  
91716 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\ユーザ名\appdata\local\programs\python\python37\DLLs\_tkinter.pyd  
91978 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\ユーザ名\appdata\local\programs\python\python37\DLLs\_tkinter.pyd  
92465 INFO: checking Tree  
92584 INFO: checking Tree  
92768 INFO: Looking for ctypes DLLs  
92794 INFO: Analyzing run-time hooks ...  
92801 INFO: Including run-time hook 'pyi_rth_multiprocessing.py'  
92808 INFO: Including run-time hook 'pyi_rth_win32comgenpy.py'  
92811 INFO: Including run-time hook 'pyi_rth_pkgres.py'  
92813 INFO: Including run-time hook 'pyi_rth__tkinter.py'  
92829 INFO: Looking for dynamic libraries  
125673 INFO: Cannot get manifest resource from non-PE file 00__text\190903_井尻.txt  
125675 WARNING: Can not get binary dependencies for file: 00__text\190903_井尻.txt  
Traceback (most recent call last):  
 File "c:\users\ユーザ名\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\depend\bindepend.py", line 721, in getImports  
   return _getImports_pe(pth)  
 File "c:\users\ユーザ名\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\depend\bindepend.py", line 103, in _getImports_pe  
   pe = pefile.PE(pth, fast_load=True)  
 File "c:\users\ユーザ名\appdata\local\programs\python\python37\lib\site-packages\pefile.py", line 1754, in __init__  
   self.__parse__(name, data, fast_load)  
 File "c:\users\ユーザ名\appdata\local\programs\python\python37\lib\site-packages\pefile.py", line 1847, in __parse__  
   raise PEFormatError('DOS Header magic not found.')  
pefile.PEFormatError: 'DOS Header magic not found.'  
125782 INFO: Cannot get manifest resource from non-PE file requests\urllib3-master\test\test_response.py  
125783 WARNING: Can not get binary dependencies for file: requests\urllib3-master\test\test_response.py  
Traceback (most recent call last):  
 File "c:\users\ユーザ名\appdata\local\programs\python\python37\lib\runpy.py", line 193, in _run_module_as_main  
   "__main__", mod_spec)  
 File "c:\users\ユーザ名\appdata\local\programs\python\python37\lib\runpy.py", line 85, in _run_code  
   exec(code, run_globals)  
 File "C:\Users\ユーザ名\AppData\Local\Programs\Python\Python37\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>  
 File "c:\users\ユーザ名\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\__main__.py", line 94, in run  
   run_build(pyi_config, spec_file, **vars(args))  
 File "c:\users\ユーザ名\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\__main__.py", line 46, in run_build  
   PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)  
 File "c:\users\ユーザ名\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\depend\bindepend.py", line 400, in getAssemblyFiles  
   for assembly in getAssemblies(pth):  
 File "c:\users\ユーザ名\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\depend\bindepend.py", line 351, in getAssemblies  
   res = GetManifestResources(pth)  
 File "c:\users\ユーザ名\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\utils\win32\winmanifest.py", line 1005, in GetManifestResources  
   return winresource.GetResources(filename, [RT_MANIFEST], names, languages)  
 File "c:\users\ユーザ名\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\utils\win32\winresource.py", line 168, in GetResources  
   hsrc = win32api.LoadLibraryEx(filename, 0, LOAD_LIBRARY_AS_DATAFILE)  
pywintypes.error: (2, 'LoadLibraryEx', '指定されたファイルが見つかりません。')  
 
```  
 
以上、よろしくお願い致します。
  • Python

    36907 questions

    Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

  • PyInstaller

    148 questions

    PyInstallerは、Pythonのスクリプトを一括でWindowsなどで動く実行可能ファイルに変換できるツールです。このツールを用いることで自作のPythonプログラムを別で使用する場合でもPythonをインストールする必要がありません。

思考するエンジニアのためのQ&Aサイト「teratail」について詳しく知る