I am trying to run a voice program in Python 3.5.2 and with pyttsx library. But I've faced up with lots of problems. First one is about engine. When I run the command import pyttsx
, compiler gave me the error like below:
ImportError: No module named 'engine'
Then I've found this answer. But it didn't work either. Eventually, I now have another - similar - error like below:
D:\Users\orcuny\Desktop\AVA>python ava.py
Traceback (most recent call last):
File "D:\Users\orcuny\AppData\Local\Continuum\Anaconda3\lib\site-packages\pyttsx\__init__.py", line 37, in init
eng = _activeEngines[driverName]
File "D:\Users\orcuny\AppData\Local\Continuum\Anaconda3\lib\weakref.py", line 131, in __getitem__
o = self.data[key]()
KeyError: None
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "ava.py", line 3, in <module>
engine = pyttsx.init()
File "D:\Users\orcuny\AppData\Local\Continuum\Anaconda3\lib\site-packages\pyttsx\__init__.py", line 39, in init
eng = Engine(driverName, debug)
File "D:\Users\orcuny\AppData\Local\Continuum\Anaconda3\lib\site-packages\pyttsx\engine.py", line 45, in __init__
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "D:\Users\orcuny\AppData\Local\Continuum\Anaconda3\lib\site-packages\pyttsx\driver.py", line 64, in __init__
self._module = __import__(name, globals(), locals(), [driverName])
ImportError: No module named 'drivers'
As far as I can get from the answers all over the SO, I assume that pyttsx library is written in Python 2.X.
My first question is, how can I solve this above problem? The second question is, I couldn't find pyttsx library which is written in Python 3.X. Can anybody enlighten me if there is any pyttsx library that is written in Python 3.X?
Thanks in advance.
EDIT: Adding site-packages to my PATH variables also didn't work.
You can install
pyttsx3
which is compatible with both python3 and python2 and is error free as far as i have tested.
Install:
pip install pyttsx3
In CMD run this command it will remove all the issue , I just tried it. pip install -Iv pyttsx3==2.6 -U
site-packages hasn't included your PY_HOME or PATH. Please open Enviroment Variables and add it to the System Variable.
Add something like below, also you will see required packages under the folder.
Hope it helps
Well, the problem seems to be addressed in the following post
import pyttsx works in python 2.7, but not in python3
Yes, please use the following version:
https://github.com/jpercent/pyttsx
It is a Python3 port of
pyttsx
which seems to address the problems you face and targets Python 3.X versions.For example the error you see (
ImportError: No module named 'drivers'
) is addressed by the following commithttps://github.com/jpercent/pyttsx/commit/f035083338f39f7d93b0c610fbef0bb55fc9fc1c
which was merged in the aforementioned repository.
To install the
pyttsx
python module, you canor
or
or do that inside a virtual environment if you use them. You can avoid using 'sudo' to install, depends on the environment you use and how you organized the packages (locations, etc.).
Of course, use the right python (python3) and pip (pip3) as you have in your environment.
Please remove and clean the previous
pyttsx
package you had there in the environment.In addition, you can visit http://pyttsx.readthedocs.io/en/latest/install.html
for more details on that.