Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/353.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python pyinstaller将pyttsx3文件转换为.exe文件后,不会执行任何操作_Python_Python 3.x_Tkinter_Pyttsx - Fatal编程技术网

Python pyinstaller将pyttsx3文件转换为.exe文件后,不会执行任何操作

Python pyinstaller将pyttsx3文件转换为.exe文件后,不会执行任何操作,python,python-3.x,tkinter,pyttsx,Python,Python 3.x,Tkinter,Pyttsx,我使用Tkinter和pyttsx3编写了一个简单的代码,它们将文本转换为语音。但是在转换为.exe文件后,没有打开任何文件并显示错误“应用程序无法运行”。我已将如此多的项目从.py转换为.exe,所有项目都运行良好,但这是第一次出现错误 import tkinter as tk import pyttsx3 engine = pyttsx3.init() class Widget(): def __init__(self): self.root = tk.Tk()

我使用Tkinter和pyttsx3编写了一个简单的代码,它们将文本转换为语音。但是在转换为.exe文件后,没有打开任何文件并显示错误“应用程序无法运行”。我已将如此多的项目从.py转换为.exe,所有项目都运行良好,但这是第一次出现错误

import tkinter as tk
import pyttsx3

engine = pyttsx3.init()


class Widget():
    def __init__(self):
        self.root = tk.Tk()
        self.root.title('TTS')
        self.root.resizable(0, 0)
        self.label1 = tk.Label(self.root, text='What do you want me to speak?')
        self.label1.pack()
        self.entry = tk.Entry(self.root)
        self.entry.pack()
        self.button = tk.Button(self.root, text='Speak!', command=self.clicked)
        self.button.pack()
        self.root.mainloop()

    def speak(self, text):
        engine.say(text)
        engine.runAndWait()

    def clicked(self):
        text = self.entry.get()
        rate = engine.getProperty('rate')
        engine.setProperty('rate', 150)
        voices = engine.getProperty('voices') 
        engine.setProperty('voice', voices[1].id)
        self.speak(text)


if __name__ == '__main__':
    widget = Widget()

请在不使用
-w
的情况下再次尝试使用pyinstaller。您可能会得到错误信息。请阅读