我使用 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 中运行良好
每次我尝试运行编程时,它们都显示错误
this is actual error
---------------------------
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 设置中手动包含缺少的模块 build_exe_options-
build_exe_options = {'packages': ['pyttsx3.drivers.sapi5']}
我使用 cx_Freeze 编译了我的代码,之前该代码在 VS Code 中运行良好 每次我尝试运行编程时,它们都显示错误
this is actual error
---------------------------
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 设置中手动包含缺少的模块 build_exe_options-
build_exe_options = {'packages': ['pyttsx3.drivers.sapi5']}