Pyttsx text to speech - ModuleNotFoundError: No module named 'engine'

Pyttsx text to speech - ModuleNotFoundError: No module named 'engine'

我在 Win10 上使用 Python3.7。我想使用 Pyttsx,但它显示错误。您知道如何解决这个问题吗?

错误:

Traceback (most recent call last): File "C:\Python37\myTest\test.py", line 2, in import pyttsx File "C:\Python37\lib\site-packages\pyttsx__init__.py", line 18, in from engine import Engine ModuleNotFoundError: No module named 'engine'

test.py:

import pyttsx
engine = pyttsx.init()
engine.say('Good morning.')
engine.runAndWait()

初始化.py:

from engine import Engine

engine.py:

class Engine(object):
def __init__(self, driverName=None, debug=False):

尝试使用 pyttsx3 而不是 pyttsx 首先安装 pyttsx3

pip install pyttsx3

并更改

import pyttsx

为了

import pyttsx3

test.py:

import pyttsx3
engine = pyttsx3.init()
engine.say('Good morning.')
engine.runAndWait()