質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
PyInstaller

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

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Tkinter

Tkinterは、GUIツールキットである“Tk”をPythonから利用できるようにした標準ライブラリである。

Q&A

解決済

1回答

5801閲覧

python tkinter構成のexe化したファイルが実行できない

Kazu

総合スコア5

PyInstaller

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

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Tkinter

Tkinterは、GUIツールキットである“Tk”をPythonから利用できるようにした標準ライブラリである。

0グッド

0クリップ

投稿2022/01/26 07:05

python pyファイルをexeファイルで実行可能にして配布したい

exeを実行した際に添付画像のようなエラーが出てしまい動作しない状況となっております。
exeファイル作成は pyinstaller ファイル名 --onefile --noconsoleで作成しております。

発生している問題・エラーメッセージ

イメージ説明

該当のソースコード抜粋

python

1import shutil 2import re, openpyxl 3import tkinter as tkm 4from tkinter import ttk 5from tkinter import * 6from tkinter.ttk import * 7from tkinter import messagebox 8from tkinter import filedialog 9from tkcalendar import DateEntry 10 11 12class Filerename(tkm.Frame): 13 def __init__(self,master): 14 super().__init__(master) 15 self.pack() 16 17 self.master.title("ファイルリネームVer1.0") 18 self.master.geometry("550x280+700+350") 19 20 self.widget() 21 22 #--------入力制限失敗時の表示-START--------- 23 def InvalidText01(self): 24 messagebox.showerror('エラー','半角数字または6文字以内で入力してください。') 25 #--------入力制限失敗時の表示-END--------- 26 27 28 #--------入力制限設定-START---------- 29 def onValidate01(self, S, P): 30 if re.match(re.compile('[0-9]+'), S) and len(P) <=6: 31 return True 32 else: 33 return False 34 #--------入力制限設定-END--------- 35 36 #---------ボタン動作-START---------- 37 #ファイル参照ボタン 38 def select_files(self): 39 idir = 'C:/USER/(ユーザー名)/Desktop' 40 fileType = [("名前変更するPDF","*.pdf")] 41 ogfile_path = filedialog.askopenfilename(filetypes=fileType, initialdir=idir, title="対象ファイル指定") 42 self.oldfile_path = ogfile_path 43 self.entry08.insert(tkm.END, ogfile_path) 44 45 #確認ボタン動作(全項目の入力漏れチェック) 46 def check(self): 47 if self.entry01.get() != "" \ 48 and self.combo02.get() != "" \ 49 and self.combo03.get() != "" \ 50 and self.entry06.get() != "" \ 51 and self.entry07.get() != "" \ 52 and self.entry08.get() != "": 53 54 #支店選択より保存先設定 55 if self.combo02.get() == "本社": 56 self.save_path = "c:/" 57 elif self.combo02.get() == "東京支店": 58 self.save_path = "c:/ 59 elif self.combo02.get() == "名古屋支店": 60 self.save_path = "c:/" 61 elif self.combo02.get() == "大阪支店": 62 self.save_path = "c:/" 63 elif self.combo02.get() == "九州支店": 64 self.save_path = "c:/" 65 else: 66 messagebox.showerror("選択エラー","支店を選択してください。") 67 68 self.entry09.configure(state = "normal") 69 self.entry09.insert(tkm.END, self.save_path) 70 self.entry09.configure(state = "readonly") 71 self.btn12['state']= 'disable' 72 self.btn13['state']= 'enable' 73 74 messagebox.showinfo("内容確認完了","ファイル名を変更してもよろしければ続けて【実行】ボタンをクリックしてください。") 75 else: 76 messagebox.showerror("エラー","全ての項目を入力してください。") 77 78 #実行ボタン動作(ファイル名変更) 79 def renameexe(self): 80 excel_master = "c:/" 81 excel_search = "c:/" 82 #Excel開き転記作業 83 wb = openpyxl.load_workbook(excel_master) 84 ws = wb['検索'] 85 rowval = int(ws.cell(row=1, column=2).value) 86 file_id = str(ws.cell(row=rowval, column=1).value) + ".pdf" 87 self.entry10.configure(state="normal") 88 self.entry10.insert(tkm.END, file_id) 89 self.entry10.configure(state="readonly") 90 ws.cell(row=rowval, column=3).value = self.entry01.get() #登録者社員番号転記 91 ws.cell(row=rowval, column=4).value = self.combo02.get() #支店転記 92 ws.cell(row=rowval, column=5).value = self.combo03.get() #種別転記 93 ws.cell(row=rowval, column=6).value = self.entry05.get() #プロジェクト番号転記 94 ws.cell(row=rowval, column=7).value = self.entry06.get() #顧客名転記 95 ws.cell(row=rowval, column=8).value = self.entry07.get() #金額転記 96 ws.cell(row=rowval, column=2).value = self.date04.get() #日付転記 97 rowval = rowval + 1 98 ws.cell(row=1, column=2).value = rowval 99 wb.save(excel_master) 100 ws.delete_rows(1) 101 wb.save(excel_search) 102 103 self.save_path = self.save_path + file_id 104 shutil.move(self.oldfile_path,self.save_path) 105 messagebox.showinfo("変更完了","ファイル保存先と変更ファイル名を確認してください。") 106 107 self.btn11['state']= 'disable' 108 self.btn12['state']= 'disable' 109 self.btn13['state']= 'disable' 110 self.btn14['state']= 'enable' 111 112 113 #クリアボタン動作(入力内容クリア) 114 def initclear(self): 115 rec = messagebox.askyesno("確認","入力内容を全てクリアしてもよろしいですか?") 116 if rec == True: 117 self.entry01.delete(0,tkm.END) 118 self.combo02.delete(0,tkm.END) 119 self.combo03.delete(0,tkm.END) 120 self.entry05.delete(0,tkm.END) 121 self.entry06.delete(0,tkm.END) 122 self.entry07.delete(0,tkm.END) 123 self.entry08.delete(0,tkm.END) 124 125 self.entry09.configure(state = "normal") 126 self.entry09.delete(0,tkm.END) 127 self.entry09.configure(state = "readonly") 128 129 self.entry10.configure(state = "normal") 130 self.entry10.delete(0,tkm.END) 131 self.entry10.configure(state = "readonly") 132 133 self.btn11['state']= 'enable' 134 self.btn12['state']= 'enable' 135 self.btn13['state']= 'disable' 136 self.btn14['state']= 'enable' 137 138 #---------ボタン動作-END---------- 139 140 #-----------パーツ設定-START---------- 141 def widget(self): 142 vcmd01 = self.register(self.onValidate01) #登録社員番号入力データ取得 143 vcmd02 = self.register(self.onValidate02) #支店入力データ取得 144 vcmd03 = self.register(self.onValidate03) #種別入力データ取得 145 vcmd05 = self.register(self.onValidate05) #プロジェクト番号入力データ取得 146 vcmd07 = self.register(self.onValidate07) #金額データ取得 147 148 self.lbl01 = ttk.Label(self.master, text="登録者社員番号", width=17, anchor="e", justify=RIGHT) 149 self.lbl02 = ttk.Label(self.master, text="支店", width=17, anchor="e", justify=RIGHT) 150 self.lbl03 = ttk.Label(self.master, text="種別", width=13, anchor="e", justify=RIGHT) 151 self.lbl04 = ttk.Label(self.master, text="日付", width=17, anchor="e", justify=RIGHT) 152 self.lbl05 = ttk.Label(self.master, text="プロジェクト番号", width=17, anchor= "e", justify=RIGHT) 153 self.lbl06 = ttk.Label(self.master, text="顧客名", width=17, anchor="e", justify=RIGHT) 154 self.lbl07 = ttk.Label(self.master, text="金額", width=17, anchor="e", justify=RIGHT) 155 self.lbl08 = ttk.Label(self.master, text="対象ファイル", width=17, anchor="e", justify=RIGHT) 156 self.lbl09 = ttk.Label(self.master, text="ファイル保存先", width=17, anchor="e", justify=RIGHT) 157 self.lbl10 = ttk.Label(self.master, text="変更後のファイル名", width=17, anchor="e", justify=RIGHT) 158 159 self.lbl01.place(x=10, y=10) 160 self.lbl02.place(x=10, y=35) 161 self.lbl03.place(x=190, y=35) 162 self.lbl04.place(x=10, y=60) 163 self.lbl05.place(x=10, y=85) 164 self.lbl06.place(x=10, y=110) 165 self.lbl07.place(x=10, y=135) 166 self.lbl08.place(x=10, y=160) 167 self.lbl09.place(x=10, y=185) 168 self.lbl10.place(x=10, y=210) 169 170 self.entry01 = ttk.Entry(self.master, justify=tkm.LEFT, width=13, 171 validate="key", 172 validatecommand=(vcmd01, '%S', '%P'), 173 invalidcommand=self.InvalidText01) 174 self.combo02 = ttk.Combobox(self.master, justify=tkm.CENTER, width=13, 175 values=[ 176 "本社", 177 "東京支店", 178 "名古屋支店", 179 "大阪支店", 180 "九州支店"], 181 validate="key", 182 validatecommand=(vcmd02, '%S'), 183 invalidcommand=self.InvalidText02) 184 185 self.combo03 = ttk.Combobox(self.master, justify=tkm.CENTER, width=13, 186 values=[ 187 "請求書", 188 "注文書", 189 "契約書", 190 "領収書"], 191 validate="key", 192 validatecommand=(vcmd03, '%S'), 193 invalidcommand=self.InvalidText03) 194 195 self.date04 = DateEntry(date_pattern='yyyy/mm/dd', width=13, 196 locale='ja_jp', 197 firstweekday='sunday', 198 showweeknumbers=False, 199 justify=CENTER) 200 self.entry05 = ttk.Entry(self.master, justify = tkm.LEFT, width = 13, 201 validate="key", 202 validatecommand=(vcmd05, '%S', '%P'), 203 invalidcommand=self.InvalidText05) 204 self.entry06 = ttk.Entry(self.master, justify=tkm.LEFT, width=60) 205 self.entry07 = ttk.Entry(self.master, justify=tkm.RIGHT, width=13, 206 validate="key", 207 validatecommand=(vcmd07, '%S'), 208 invalidcommand=self.InvalidText07) 209 self.entry08 = ttk.Entry(self.master, justify=tkm.LEFT, width=60) 210 self.entry09 = ttk.Entry(self.master, justify=tkm.LEFT, width=60, state="readonly") 211 self.entry10 = ttk.Entry(self.master, justify=tkm.LEFT, width=60, state="readonly") 212 self.btn11 = ttk.Button(self.master, text="参照", width=6, command=self.select_files) 213 self.btn12 = ttk.Button(self.master, text="確認", width=10, state="enable", command=self.check) 214 self.btn13 = ttk.Button(self.master, text="実行", width=10, state="disable", command=self.renameexe) 215 self.btn14 = ttk.Button(self.master, text="クリア", width=10, command=self.initclear) 216 #-----------パーツ設定-END---------- 217#起動 218def main(): 219 root = tkm.Tk() 220 app = Filerename(master = root) 221 app.mainloop() 222 223if __name__ == "__main__": 224 225 main() 226

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

How can I generate the exe application from python file [duplicate]と同じ問題です。

Shell

1pyinstaller -F --hidden-import "babel.numbers" ソースコード.py

のようにして、babelモジュールを同梱させるようにしましょう。

投稿2022/01/26 07:17

ppaul

総合スコア24666

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

Kazu

2022/01/27 05:22

ありがとうございます。 ご教授いただいたコマンド実行で無事にexeファイルの作成ができました。 また、配布後の利用も確認できました。 ありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問