繁体   English   中英

我使用 cx_Freeze 编译了我的 python 代码,代码在它之前运行良好,现在它显示此错误有人可以帮助我吗?

[英]I complied my python code using cx_Freeze, code is working good before it & now it is showing this error can anyone help me?

我使用 cx_Freeze 编译了我的代码,并且在每次尝试运行程序时该代码在 VS Code 中运行良好之前,它们都显示错误

这是实际错误

---------------------------

cx_Freeze: Python error in main script
---------------------------
Traceback (most recent call last):
     File "C:\Python36\lib\site-packages\pyttsx3\__init__.py", line 20, in init
       eng = _activeEngines[driverName]
     File "C:\Python36\lib\weakref.py", line 131, in __getitem__
      o = self.data[key]()
KeyError: 'sapi5'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Python36\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 40, in run
  module.run()
File "C:\Python36\lib\site-packages\cx_Freeze\initscripts\Console.py", line 37, in run
 exec(code, {'__name__': '__main__'})
File "ZIM.py", line 26, in <module>
File "C:\Python36\lib\site-packages\pyttsx3\__init__.py", line 22, in init
  eng = Engine(driverName, debug)
File "C:\Python36\lib\site-packages\pyttsx3\engine.py", line 30, in __init__
  self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "C:\Python36\lib\site-packages\pyttsx3\driver.py", line 50, in __init__
  self._module = importlib.import_module(name)
File "C:\Python36\lib\importlib\__init__.py", line 126, in import_module
  return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'pyttsx3.drivers.sapi5'

---------------------------
OK   
---------------------------

您需要在 cx_freeze setup build_exe_options- 中手动包含缺少的模块

build_exe_options = {'packages': ['pyttsx3.drivers.sapi5']}

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM