简体   繁体   English

致命错误:无法执行“脚本名称”| 自动 py 到 exe

[英]Fatal Error: Failed to execute "script name" | auto-py-to-exe

This is the code.这是代码。 I'm compiling it to an exe with auto-py-to-exe.我正在使用 auto-py-to-exe 将其编译为 exe。

from tkinter import *
import os

master = Tk()
master.title('Power Options')
master.geometry("300x100")
master.wm_iconbitmap("poweroptions.ico")

def fun():
    os.system('cmd /k shutdown /s /f /t 0')

def fun2():
    os.system('cmd /k shutdown /r /f /t 0')

def fun3():
    os.system("rundll32.exe powrprof.dll,SetSuspendState 0,1,0")

b1 = Button(master,text = "  Shutdown  ",command = fun,activeforeground = "red",activebackground = "pink",padx=10)
b2 = Button(master,text = "   Restart   ",command = fun2,activeforeground = "red",activebackground = "pink",padx=10)
b3 = Button(master,text = "    Sleep    ",command = fun3,activeforeground = "red",activebackground = "pink",padx=10)

b3.place(relx=0.5, rely=0.5, anchor=CENTER)
b1.place(relx=0.1, rely=0.5, anchor=W)
b2.place(relx=0.9, rely=0.5, anchor=E)

master.mainloop()

When I compile it, it gives me the error in the title when I run it.当我编译它时,它在我运行它时给了我标题中的错误。 The script runs fine when I run it as a python (.py) file.当我将它作为 python (.py) 文件运行时,该脚本运行良好。

Solved it.解决了。 Just needed to delete "master.wm_iconbitmap("poweroptions.ico")" because I was not using it.只需要删除“master.wm_iconbitmap("poweroptions.ico")”,因为我没有使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何编码以修复检测到的致命错误:使用 auto-py-to-exe 将 python 代码编译为 exe 文件后无法执行脚本 BoxDetection? - How to coding to fix Fatal error detected : Failed to execute script BoxDetection after use auto-py-to-exe compile python code to exe file? 运行由 auto-py-to-exe 生成的 an.exe 时出错 - error while running an .exe generated by auto-py-to-exe Pywhatkit 和 auto-py-to-exe - Pywhatkit and auto-py-to-exe 使用 auto-py-yo-exe NameError 使 python 可执行文件之前出错:未定义名称 '__version__' [3644] 无法执行脚本 - Error before make the python executable with auto-py-yo-exe NameError: name '__version__' is not definied [3644] Failed to execute the script 安装auto-py-to-exe时出错如何解决? - How to solve error when installing auto-py-to-exe? 安装 pip package auto-py-to-exe 时出错 - Error in installing pip package auto-py-to-exe Pyinstaller - “致命错误! 将脚本转换为 exe 时无法执行脚本” - Pyinstaller - “Fatal error ! Failed to execute script” when converting script to exe auto-py-to-exe:未找到模块请求 - auto-py-to-exe : module requests not found 没有名为“pandas”的模块 auto-py-to-exe - No module named 'pandas' auto-py-to-exe 无法安装或使用 auto-py-to-exe - Unable to install and or use auto-py-to-exe
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM