[英]Pyinstaller - Failed to execute script pyi_rth__tkinter
我正在尝试使用 pyinstaller 将我的 Python tkinter 记事本转换为 exe。 但是当我打开创建的 exe 文件时,我得到了错误:
Failed to execute script pyi_rth__tkinter
我尝试将 pyinstaller 版本从 github 更改为 5.0 开发人员并导入 pkg_resources.py2_warn 但这没有用,我得到了同样的错误。 我正在使用 python 3.9.1 这是我的代码:
from tkinter import *
from tkinter import filedialog
from PIL import ImageTk
from PIL import Image
root = Tk()
root.geometry("600x375")
root.resizable(False, False)
root.title("NetNote")
root.iconbitmap("ikona.ico")
#liczba globalna zapisz
global open_status_name
open_status_name = False
def usuwanie():
text.delete(1.0, END)
global open_status_name
open_status_name = False
def open_txt():
text_file = filedialog.askopenfilename(title="Open Text File", filetypes=(("Text Files", "*.txt"),))
if text_file:
global open_status_name
open_status_name = text_file
text_file = open(text_file, "r")
stuff = text_file.read()
text.delete("1.0", END)
text.insert(END, stuff)
text_file.close()
#fukcja - save as
def save_as():
text_file=filedialog.asksaveasfilename(defaultextension=".*", title="Zapisz jako", filetypes=(("Text Files", "*.txt"),))
if text_file:
name = text_file
name = name.replace("","")
text_file = open(text_file, "w")
text_file.write(text.get(1.0, END))
text_file.close()
def save_file():
global open_status_name
if open_status_name:
text_file = open(open_status_name, "w")
text_file.write(text.get(1.0, END))
text_file.close()
else:
save_as()
frame = LabelFrame(root, text="Menu",padx=2, pady=2)
frame.grid(row=0, column=0, sticky=S, padx=10, pady=10)
my_logo = Image.open("logo.png")
resized = my_logo.resize((110, 138), Image.ANTIALIAS)
my_logo = ImageTk.PhotoImage(file="logo.png")
new_pic = ImageTk.PhotoImage(resized)
my_label = Label(root, image=new_pic)
my_label.grid(row=0, column=0, sticky=N, pady=20)
przycisk1 = Button(frame, text="Nowy",width=8, height=1, command=usuwanie,)
przycisk1.grid(row=0,column=0, sticky=N, padx=10, pady=10,)
przycisk2 = Button(frame, text="Otwórz", width=8,height=1, command=open_txt)
przycisk2.grid(row=1, column=0,)
root.mainloop
przycisk3 = Button(frame, text="Zapisz jako", width=8,height=1,command=save_as)
przycisk3.grid(row=2, column=0, padx=10, pady=10)
text = Text(root, height=20, width=57, font=("Calibri, 11"))
text.grid(row=0, column=1, padx=10, pady=10)
przycisk4 = Button(frame, text="Zapisz", width=8, height=1, command=save_file)
przycisk4.grid(row=3, column=0, pady=(0, 10))
root.mainloop
你可以试试这个方法:
pyinstaller --onefile -w
甚至我使用 Tkinter 创建了一个记事本,这种方法对我有用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.