pyttsx3: pyttsx3 fails to execute when compiled
Error when running Executable created with PyInstaller 3.3 on Windows 10 64-bit and Python v3.6.
[pyttsx3_error.txt](https://github.com/nateshmbhat/pyttsx3/files/1455369/pyttsx3_error.txt)
Example Script:
# import the speech to text module
import pyttsx3
# Initialize the Speech Engine
engine = pyttsx3.init()
# Set the words per minute rate of the Speech engine
engine.setProperty('rate', 105)
# Tell the engine what you want it to say.
engine.say('Sally sells seashells by the seashore.')
engine.say('The quick brown fox jumped over the lazy dog.')
# Tell the engine to start saying what you wanted it to and stop when it reaches the end of the queued sayings.
engine.runAndWait()
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 16 (1 by maintainers)
try installing “pip install pyttsx3==2.71”
I am using python 3.8
`import pyttsx3
engian = pyttsx3.init() engian.say(“hi”) engian.runAndWait()`
I am getting error like this
`Traceback (most recent call last): File “C:\python3.8\lib\site-packages\pyttsx3_init_.py”, line 20, in init
eng = _activeEngines[driverName] File “C:\python3.8\lib\weakref.py”, line 131, in getitem o = self.datakey KeyError: None
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File “c:/Users/pande/Desktop/New folder/jarvis.py”, line 4, in <module> engian = pyttsx3.init() File “C:\python3.8\lib\site-packages\pyttsx3_init_.py”, line 22, in init eng = Engine(driverName, debug) File “C:\python3.8\lib\site-packages\pyttsx3\engine.py”, line 30, in init self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug) File “C:\python3.8\lib\site-packages\pyttsx3\driver.py”, line 50, in init self.module = importlib.import_module(name) File "C:\python3.8\lib\importlib_init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File “<frozen importlib._bootstrap>”, line 1014, in _gcd_import File “<frozen importlib._bootstrap>”, line 991, in _find_and_load File “<frozen importlib._bootstrap>”, line 975, in _find_and_load_unlocked File “<frozen importlib._bootstrap>”, line 671, in _load_unlocked File “<frozen importlib._bootstrap_external>”, line 783, in exec_module File “<frozen importlib._bootstrap>”, line 219, in _call_with_frames_removed File “C:\python3.8\lib\site-packages\pyttsx3\drivers\sapi5.py”, line 10, in <module> import pythoncom ModuleNotFoundError: No module named ‘pythoncom’` I am in win 10
Example of what fixes the No module named pyttsx3.drivers error:
These are the key lines: from PyInstaller.utils.hooks import collect_submodules my_hidden_imports = collect_submodules(‘pyttsx3’) hiddenimports=my_hidden_imports,
This is a .spec file I created that collects all of the pyttsx3 submodules:
Example hook file for pyttsx3 that avoids needing to add any of that into the spec file:
Current Error when trying to run pyttsx3 from a Windows 10 64-bit Pyinstaller compiled executible.
Traceback (most recent call last): File “site-packages\pyttsx3_init_.py”, line 44, in init File “c:\users\my_user\appdata\local\programs\python\python36\lib\weakref.py”, line 137, in getitem o = self.datakey KeyError: ‘sapi5’
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File “pyttsx3_example.py”, line 9, in <module> engine = pyttsx3.init(‘sapi5’) File “site-packages\pyttsx3_init_.py”, line 46, in init File “site-packages\pyttsx3\engine.py”, line 52, in init File “site-packages\pyttsx3\driver.py”, line 77, in init File “site-packages\pyttsx3\drivers\sapi5.py”, line 22, in buildDriver File “site-packages\pyttsx3\drivers\sapi5.py”, line 41, in init File “site-packages\pyttsx3\drivers\sapi5.py”, line 83, in setProperty File “site-packages\win32com\client\dynamic.py”, line 549, in setattr pywintypes.com_error: (-2147352573, ‘Member not found.’, None, None) [2244] Failed to execute script pyttsx3_example
Traceback (most recent call last): File “site-packages\pyttsx3_init_.py”, line 44, in init File “c:\users\MyUser\appdata\local\programs\python\python36\lib\weakref.py”, line 137, in getitem o = self.datakey KeyError: None
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File “pyttsx3_example.py”, line 9, in <module> File “site-packages\pyttsx3_init_.py”, line 46, in init File “site-packages\pyttsx3\engine.py”, line 52, in init File “site-packages\pyttsx3\driver.py”, line 75, in init File “importlib_init_.py”, line 126, in import_module File “<frozen importlib._bootstrap>”, line 994, in _gcd_import File “<frozen importlib._bootstrap>”, line 971, in _find_and_load File “<frozen importlib._bootstrap>”, line 941, in _find_and_load_unlocked File “<frozen importlib._bootstrap>”, line 219, in _call_with_frames_removed File “<frozen importlib._bootstrap>”, line 994, in _gcd_import File “<frozen importlib._bootstrap>”, line 971, in _find_and_load File “<frozen importlib._bootstrap>”, line 953, in _find_and_load_unlocked ModuleNotFoundError: No module named ‘pyttsx3.drivers’ [10288] Failed to execute script pyttsx3_example
Check this #1