0

我使用命令安装了 pyttsx3 pip install pyttsx3,然后当我运行该程序时出现错误。

该程序 :

import pyttsx3
engine = pyttsx3.init()

rate = engine.getProperty('rate')
print (rate)
engine.setProperty('rate', 125)

volume = engine.getProperty('volume')
print (volume)
engine.setProperty('volume',1.0)

voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)

engine.say("Hello World!")
engine.say('My current speaking rate is ' + str(rate))
engine.runAndWait()
engine.stop()

错误 :

raise ImportError("No system module '%s' (%s)" % (modname, filename))
ImportError: No system module 'pywintypes' (pywintypes37.dll)

我希望你能帮帮我...

4

1 回答 1

0

您使用的是什么版本的 pytts3 或 python?尝试重新安装或更新 pyttsx,因为此代码在我的机器上完美运行,您可以检查输出 这里

卸载当前的 pyttsx3 pip uninstall pyttsx3

然后重新安装。还要更新你的 python 版本。

嗨,Noe,所以问题是您在单个系统中安装了多个版本的 Python,如果您的系统上安装了多个 Python 版本,您有两种选择:

1.由于只有一个解释器可以作为Python文件类型的默认应用程序,所以你应该从你正在使用的IDE中更改python解释器,然后安装pyttsx。

2.您可以通过创建虚拟环境来安装它。用最新的python版本创建一个虚拟环境,激活你的虚拟环境,然后在环境中安装包。如果您使用 anaconda,请执行以下命令:

conda create --name env_name python=3.9

activate env_name

或者,如果您使用的是 python 默认 ide,您可以检查此链接以创建虚拟环境。

于 2020-11-11T06:23:33.063 回答