简体   繁体   中英

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

I complied my code using cx_Freeze and before that code is working good in VS Code every time I try to run program they are showing error

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   
---------------------------

You need to manually inlcude the missing module in cx_freeze setup build_exe_options-

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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