pyttsx: No module named 'engine'

2019-01-14 06:36发布

I'm trying to install TTS package by using this. Everything was okay until I tried to execute the following command:

import pyttsx

I got back this error:

File "/usr/local/lib/python3.4/dist-packages/pyttsx/__init__.py", line 18, in module <br>
    from engine import Engine<br>
ImportError: No module named 'engine'

Any help would be appreciated. Thank you!

7条回答
劫难
2楼-- · 2019-01-14 07:33

Modify site_packages/pyttsx/init.py "from engine import Engine" to

from .engine import Engine

Modify site_packages/pyttsx/engine.py "import driver" to

from . import driver

Reason: The import statement "from engine import Engine" tells python to import Engine module from directory engine. In our case engine is not a directory, it's a python file, engine.py. So we need to tell python to import this engine module from current directory (".").

查看更多
登录 后发表回答