鱼C论坛

 找回密码
 立即注册
查看: 2941|回复: 9

[已解决]pyttsx3的错误

[复制链接]
发表于 2020-3-2 19:33:13 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. Traceback (most recent call last):
  2.   File "C:\Users\C语言大神\AppData\Local\Programs\Python\Python38\Lib\site-packages\pyttsx3\drivers\sapi5.py", line 10, in <module>
  3.     import pythoncom
  4.   File "C:\Users\C语言大神\AppData\Local\Programs\Python\Python38\lib\site-packages\pythoncom.py", line 2, in <module>
  5.     import pywintypes
  6. ModuleNotFoundError: No module named 'pywintypes'
复制代码


最佳答案
2020-3-2 19:38:05
先安装 pywin32 第三方库再运行程序。

或者使用这种方法:https://fishc.com.cn/thread-156688-1-1.html
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-3-2 19:34:41 | 显示全部楼层
我这里Python3.8没有问题啊
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-3-2 19:35:32 | 显示全部楼层
在 cmd 里面执行以下命令:

  1. pip install pywin32
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-3-2 19:36:42 | 显示全部楼层
qiuyouzhi 发表于 2020-3-2 19:34
我这里Python3.8没有问题啊



你骗人,Python 3.8 根本不能用 Pyttsx3:

  1. Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32
  2. Type "help", "copyright", "credits" or "license()" for more information.
  3. >>> import pyttsx3
  4. >>> engine = pyttsx3.init()
  5. Traceback (most recent call last):
  6.   File "C:\Users\Angel\AppData\Local\Programs\Python\Python38\lib\site-packages\pyttsx3\__init__.py", line 20, in init
  7.     eng = _activeEngines[driverName]
  8.   File "C:\Users\Angel\AppData\Local\Programs\Python\Python38\lib\weakref.py", line 131, in __getitem__
  9.     o = self.data[key]()
  10. KeyError: None

  11. During handling of the above exception, another exception occurred:

  12. Traceback (most recent call last):
  13.   File "C:\Users\Angel\AppData\Local\Programs\Python\Python38\lib\site-packages\pyttsx3\drivers\sapi5.py", line 3, in <module>
  14.     from comtypes.gen import SpeechLib  # comtypes
  15. ImportError: cannot import name 'SpeechLib' from 'comtypes.gen' (C:\Users\Angel\AppData\Local\Programs\Python\Python38\lib\site-packages\comtypes\gen\__init__.py)

  16. During handling of the above exception, another exception occurred:

  17. Traceback (most recent call last):
  18.   File "C:\Users\Angel\AppData\Local\Programs\Python\Python38\lib\ctypes\__init__.py", line 123, in WINFUNCTYPE
  19.     return _win_functype_cache[(restype, argtypes, flags)]
  20. KeyError: (<class 'ctypes.HRESULT'>, (<class 'comtypes.automation.tagVARIANT'>, <class 'comtypes.LP_POINTER(ISpeechRecoGrammar)'>), 0)

  21. During handling of the above exception, another exception occurred:

  22. Traceback (most recent call last):
  23.   File "<pyshell#1>", line 1, in <module>
  24.     engine = pyttsx3.init()
  25.   File "C:\Users\Angel\AppData\Local\Programs\Python\Python38\lib\site-packages\pyttsx3\__init__.py", line 22, in init
  26.     eng = Engine(driverName, debug)
  27.   File "C:\Users\Angel\AppData\Local\Programs\Python\Python38\lib\site-packages\pyttsx3\engine.py", line 30, in __init__
  28.     self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
  29.   File "C:\Users\Angel\AppData\Local\Programs\Python\Python38\lib\site-packages\pyttsx3\driver.py", line 50, in __init__
  30.     self._module = importlib.import_module(name)
  31.   File "C:\Users\Angel\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py", line 127, in import_module
  32.     return _bootstrap._gcd_import(name[level:], package, level)
  33.   File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  34.   File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  35.   File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  36.   File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  37.   File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  38.   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  39.   File "C:\Users\Angel\AppData\Local\Programs\Python\Python38\lib\site-packages\pyttsx3\drivers\sapi5.py", line 6, in <module>
  40.     engine = comtypes.client.CreateObject("SAPI.SpVoice")
  41.   File "C:\Users\Angel\AppData\Local\Programs\Python\Python38\lib\site-packages\comtypes\client\__init__.py", line 250, in CreateObject
  42.     return _manage(obj, clsid, interface=interface)
  43.   File "C:\Users\Angel\AppData\Local\Programs\Python\Python38\lib\site-packages\comtypes\client\__init__.py", line 188, in _manage
  44.     obj = GetBestInterface(obj)
  45.   File "C:\Users\Angel\AppData\Local\Programs\Python\Python38\lib\site-packages\comtypes\client\__init__.py", line 110, in GetBestInterface
  46.     mod = GetModule(tlib)
  47.   File "C:\Users\Angel\AppData\Local\Programs\Python\Python38\lib\site-packages\comtypes\client\_generate.py", line 110, in GetModule
  48.     mod = _CreateWrapper(tlib, pathname)
  49.   File "C:\Users\Angel\AppData\Local\Programs\Python\Python38\lib\site-packages\comtypes\client\_generate.py", line 184, in _CreateWrapper
  50.     mod = _my_import(fullname)
  51.   File "C:\Users\Angel\AppData\Local\Programs\Python\Python38\lib\site-packages\comtypes\client\_generate.py", line 24, in _my_import
  52.     return __import__(fullname, globals(), locals(), ['DUMMY'])
  53.   File "C:\Users\Angel\AppData\Local\Programs\Python\Python38\lib\site-packages\comtypes\gen\_C866CA3A_32F7_11D2_9602_00C04F8EE628_0_5_4.py", line 1961, in <module>
  54.     ISpeechRecoContext._methods_ = [
  55.   File "C:\Users\Angel\AppData\Local\Programs\Python\Python38\lib\site-packages\comtypes\__init__.py", line 329, in __setattr__
  56.     self._make_methods(value)
  57.   File "C:\Users\Angel\AppData\Local\Programs\Python\Python38\lib\site-packages\comtypes\__init__.py", line 698, in _make_methods
  58.     prototype = WINFUNCTYPE(restype, *argtypes)
  59.   File "C:\Users\Angel\AppData\Local\Programs\Python\Python38\lib\ctypes\__init__.py", line 125, in WINFUNCTYPE
  60.     class WinFunctionType(_CFuncPtr):
  61. TypeError: item 1 in _argtypes_ passes a union by value, which is unsupported.
  62. >>>
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-3-2 19:37:45 | 显示全部楼层
一个账号 发表于 2020-3-2 19:36
你骗人,Python 3.8 根本不能用 Pyttsx3:


我以为是Pythoncom
我现在试试
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-3-2 19:38:05 | 显示全部楼层    本楼为最佳答案   
先安装 pywin32 第三方库再运行程序。

或者使用这种方法:https://fishc.com.cn/thread-156688-1-1.html
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-3-2 19:39:09 | 显示全部楼层
一个账号 发表于 2020-3-2 19:36
你骗人,Python 3.8 根本不能用 Pyttsx3:

是只有Python2才行是吗
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-3-2 19:40:00 | 显示全部楼层
qiuyouzhi 发表于 2020-3-2 19:39
是只有Python2才行是吗

3.7.4 以下才能使用 Pyttsx3
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-3-2 19:41:31 | 显示全部楼层
一个账号 发表于 2020-3-2 19:40
3.7.4 以下才能使用 Pyttsx3

我这是新电脑,没有Python3.7.4。。。
到时候我再试试,谢谢!
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-3-2 19:43:58 | 显示全部楼层
一个账号 发表于 2020-3-2 19:40
3.7.4 以下才能使用 Pyttsx3

不一定
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-10-23 05:27

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表