import pyttsx works in python 2.7, but not in python3

pyttsx3 save to file
modulenotfounderror: no module named 'engine
pip install
how to install pyttsx in python
no matching distribution found for pyttsx3
pyttsx example
pyttsx3 in pycharm
engine getproperty voices

Question: why is python3 unable to find the engine module when importing pyttsx?

Details:

I'm doing this on a raspberry pi with Raspbian Wheezy

Under python 2.7, the following works:

>>> import pyttsx

Under python3, the following happens:

>>> import pyttsx
Traceback (etc...)
 File "<stdin>", line 1, in <module>
 File "/usr/local/lib/python3.2/dist-packages/pyttsx-1.1-py3.2.egg/pyttsx/__init__.py", line 18, in <module>
ImportError: No module named engine

I've installed and used sudo pip install pyttsx

I've imported sys

sys.path contains this...

>>> print (sys.path) 
['','/usr/local/lib/python3.2/dist-packages/setuptools-5.4.1-py3.2.egg', '/usr/local/lib/python3.2/dist-packages/pyttsx-1.1-py3.2.egg', '/usr/lib/python3.2','usr/lib/python3.2/plat-linux2', '/usr/lib/python3.2/lib-dynload','/usr/local/lib/python3.2/dist-packages','/usr/lib/python3/dist-packages']

ls /usr/local/lib/python3.2/dist-packages results in...

easy-install.pth pyttsx-1.1-py3.2.egg setuptools-5.4.1-py3.2.egg setuptools.pth

unzip -t /usr/local/lib/python3.2/dist-packages/pyttsx-1.1-py3.2.egg shows....

pyttsx/__init__.py  OK
pyttsx/voice.py   OK
pyttsx/engine.py  OK
(etc...)
No errors detected in compressed data of pyttsx-1.1-py3.2.egg

Thanks for your help!

I believe you are looking for the library:

pyttsx3

This python3 compatible version is now packaged in pypi and works pretty well for both python2 and python3 and as far as i have tested , it didn't give any error.

just use :

pip install pyttsx3

Usage :

import pyttsx3
engine = pyttsx3.init()
engine.say("I am talking now ");
engine.setProperty('rate',100)  
engine.runAndWait();

pyttsx3 not working with python 3.7.1 · Issue #29 · nateshmbhat , I believe you are looking for the library: pyttsx3. This python3 compatible version is now packaged in pypi and works pretty well for both python2 and python3  pyttsx does not seem to be designed for python 3, see pyttsx: No module named 'engine' but the answer there did not make it work for me. – Tadhg McDonald-Jensen Mar 31 '16 at 4:13 to install espeak just go to the dowload section of the sourceforge site and once it is installed the code you provided should work but I'm not certain since I'm

I attempted to install pyttsx on Python 3.4 (on Windows). Here's what I discovered:

The pyttsx found on PyPi was developed by Peter Parente on GitHub.

Parente has abandoned further development, and never ported it to Python 3. I cannot even get his version to install on Python 3. I am not sure how you managed this.

A user called James Percent forked it and made a fairly minimal attempt to make it Python 3 compatible.

I found that attempt didn't go far enough, because - while I could install it and even import pyttsx successfully, when I tried to call pyttsx.init() it would do a dynamic import of a driver, and fail with an import error.

I made a further fork to fix that, which I will submit to James Percent. With those changes in place, I am able to run @Khanrad's test script.

pyttsx3 · PyPI, I am having trouble to get pyttsx to work with python 3.7.1 Traceback (most recent call #2 Are you trying to run a file you've compiled with pyinstaller? / AlexaWrapper/skill_env/lib/python3.7/site-packages/pyttsx3/drivers/nsss.py", line 2, Iwas getting an error "no module named pyttsx3" at the import line. Text to Speech (TTS) library for Python 2 and 3. Works without internet connection or delay. Supports multiple TTS engines, including Sapi5, nsss, and espeak.

In python 3 Try this:

pip install pyttsx3

if it gives an error of engine like "engine is not found" then try to install this.

pip install python-engineio

pyttsx: No module named 'engine', Text to Speech (TTS) library for Python 2 and 3. Unlike alternative libraries, it works offline, and is compatible with both Python 2 and 3. named win32, or No module named win32api, you will need to additionally install pypiwin32. Usage : import pyttsx3 engine = pyttsx3.init() engine.say("I will speak this text") engine. I don't yet understand Python3 well enough, but the Python path was not going into pyttsx to see drivers directory, so explicitly encourage it to do so. Julian-O changed the title Fix "ImportError: No module named '.drivers'" upon init().

I'm not sure what you are trying to do...

In python 3, you have to call engine:

engine = pyttsx.init()
engine.say("What you want to say")
engine.runAndWait()

Traps for the Unwary in Python's Import System, Pyttsx is a good text to speech conversion library in python but it was written The codes in this repos are slightly modified version of the pyttsx module of python 2.x and is a Note : pyttsx3 library now works for both python2 and python3 and is also import pyttsx3; engine = pyttsx3.init(); engine.say("I will speak this text");  I am having trouble to get pyttsx to work with python 3.7.1 Traceback (most recent call last): File "C:\Users\jakeb\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyttsx_init_.py", line 37, in init eng = _activeEngines[drive

pyttsx: No module named 'engine' - text-to-speech - iOS, Then I clicked on the "+" sign available beside the package-table. Comments. Possible duplicate of import pyttsx works in python 2.7, but not in python3. There is a  This is a Python3 port of pyttsx, which is a cross-platform Python wrapper for text-to-speech synthesis. import pyttsx engine = pyttsx.init() engine.say('Greetings!') engine.say('How are you today?') engine.runAndWait() See pyttsx.readthedocs.org for documentation of the full API. – Shreshtha Garg Apr 20 '17 at 10:11

Installing pyttsx, With that layout and the current working directory being project , Python 2.7 gives the python3 -c "import example.foo" Hello from example.foo on sys.path that match the desired package name, but do not include an __init__.py file. import pyttsx работает в python 2.7, но не в python3. Вопрос: почему python3 не может найти модуль двигателя при импорте pyttsx? Детали: Я делаю это на малиновой пи с Raspbian Wheezy

import pyttsx works in python 2.7, but not in python3. Can anybody enlighten me if there is any pyttsx library that is written in Python 3.X? Drop support for Python 2.6 and older¶. While you can make Python 2.5 work with Python 3, it is much easier if you only have to work with Python 2.7. If dropping Python 2.5 is not an option then the six project can help you support Python 2.5 & 3 simultaneously (pip install six).

Comments
  • James Percent has merged my pull request. I recommend using his fork, as it is more likely to be maintained.
  • Can you confirm you have seen pyttsx work in Python 3, or is this hypothetical?
  • @oddthinking said it wasn't available. At the time yes, it was hypothetical