为什么我的.exe文件只是给我一个Pyinstaller错误?

2024-06-15 08:28:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图用pyinstaller将我的.pyw转换成.exe,但总是给我一个错误。但我试着转换最短版本的代码,它是有效的。我该怎么办

它与一个图像文件夹有依赖关系,但即使将该文件夹放在.exe的同一目录中,也会失败。 代码的最短版本为:

from tkinter import * 
from PIL import Image, ImageTk
from tkinter import messagebox

messagebox.showinfo("Hello World", "Hello World")

root=Tk()
root2=Tk()
root3=Tk()

myFrame=Frame()
myFrame.pack(fill="both", expand="True")

disc=Canvas(root, bg="black", width="600", height="600", bd=-1)

def _create_circle(self, x, y, r, **kwargs):
    return self.create_oval(x-r, y-r, x+r, y+r, **kwargs)

Canvas.create_circle = _create_circle

disc.create_circle(300, 300, 300, fill="white", outline="")

root.title("Geometria Hiperbòlica")
root.iconbitmap("Imatges\\Disc_de_Poincaré.ico")
root.resizable(0,0)

root2.title("Resultats")
root2.iconbitmap("Imatges\\Disc_de_Poincaré.ico")
root2.config(width=300, height=100)
root2.resizable(0,0)
root2.config(bd=20, relief="sunken", bg="grey")

root3.title("Instruccions")
root3.iconbitmap("Imatges\\Disc_de_Poincaré.ico")
root3.config(width=300, height=100)
root3.resizable(0,0)
root3.config(bd=20, relief="sunken", bg="grey")
myFrame.config(bg="grey")
disc.pack()
root.mainloop()

我也不知道如何找出错误的原因,所以如果需要,我可以发布完整的代码。 谢谢


Tags: 代码fromimportconfigcreaterootwidthtk