在使用PY2EXE编译脚本后,程序不会启动



用py2exe编译程序后,它不会启动,唯一出现的是命令提示快速在屏幕上闪烁(图1)

图1:https://gyazo.com/088BF4AD71D11D8025CEFFB1E3FA67D5

这是我的py2exe设置脚本:https://gyazo.com/884368e712a402101f3ed5549799e826

在我打开它之前,在文件夹中添加的所有依赖项(如图片和其他内容)。

编辑:示例代码

import subprocess
import os
import platform
import sys
from Tkinter import *
from PIL import ImageTk, Image
menu=Tk()
menu.wm_title("xCheat")
def reset():
    img=ImageTk.PhotoImage(Image.open("mcomain.png"))
    imglabel=Label(menu, image=img).grid(row=0, column=0,columnspan=2)
    test3=Label(text="Coded By Jmilicev",fg="black",font="Arial 10")
    test3.grid(row=12,column=0,columnspan=2)
    test3.grid(sticky="WE")
    resource_dir = os.path.join(os.path.dirname(__file__), 'resources');
    def Button1():
        os.startfile(os.path.join(resource_dir, 'LastActivityViewer.exe'))
    def Button2():
        os.startfile(os.path.join(resource_dir, 'pho.exe'))
    def Button3():
        os.startfile(os.path.join(resource_dir, 'procexp.exe'))
    def Button4():
        os.startfile(os.path.join(resource_dir, 'IJ.exe'))
    def Button5():
        os.startfile(os.path.join(resource_dir, 'Br.exe'))
    def Button22():
        os.startfile(os.path.join(resource_dir, 'sky.bat'))
    def Programs():
        b1=Button(text="Last Activity Viewer",fg="red",bg="black",command=Button1)
        b1.grid(row=1,column=0)
        b1.grid(sticky="WE,NS")
        b1.config(height=4,width=0)
        b2=Button(text="Process Hacker",fg="red",bg="black",command=Button2)
        b2.grid(row=1,column=1)
        b2.grid(sticky="WE,NS")
        b2.config(height=4,width=0)
        b3=Button(text="Process Explorer",fg="red",bg="black",command=Button3)
        b3.grid(row=2,column=0)
        b3.grid(sticky="WE,NS")
        b3.config(height=4,width=0)
        b14=Button(text="Search Everything",fg="red",bg="black",command=Button14)
        b14.grid(row=2,column=1)
        b14.grid(sticky="WE,NS")
        b14.config(height=4,width=0)

    menu.mainloop()
reset()

可能有很多事情,错误报告将有助于确定原因。

在命令提示符中运行程序并共享输出。

py2exe的一个很好的替代方法是cx_freeze,一些示例代码:

# run this code as: compile.py
import cx_Freeze
executables = [cx_Freeze.Executable("xCheat.py")]
cx_Freeze.setup(
    name="xCheat",
    options={"build_exe": {"packages":["LIBRARY_NAME",],
                           "include_files":[]}},  # accepts directory names
    executables = executables
)

最新更新