![](/img/trans.png)
[英]Python AttributeError: 'module' object has no attribute 'init'
[英]Pyttsx: AttributeError: 'module' object has no attribute 'init'
大家好,謝謝
import pyttsx
engine = pyttsx.init()
engine.say('Hello World')
engine.runAndWait()
我得到這個錯誤:
Traceback (most recent call last):
File "C:\Users\xxx\eclipse\workspace\Ai_Project\AI\Ai_Brain.py", line 8, in <module>
engine = pyttsx.init()
AttributeError: 'module' object has no attribute 'init'
我在Windows 7上使用Python 2.7和Eclipse Neon。 這是某種兼容性問題嗎? 我搜索了很多相關問題,但對我的案例應用答案並不能解決錯誤
導入pyttsx
模塊后:
import pyttsx
使用命令
dir(pyttsx)
您的輸出將是
['Engine',
'__builtins__',
'__doc__',
'__file__',
'__name__',
'__package__',
'__path__',
'_activeEngines',
'driver',
'drivers',
'engine',
'init',
'weakref']
(請參閱末尾的'init'
)。
我猜你的輸出會有所不同 -它將揭示哪些模塊,你居然不管其名稱的進口pyttsx
。
我猜很容易,如果將來有人遇到相同的問題並且他/她進行的每個查詢都行不通,我會發布答案。 將此視為人為錯誤,並檢查您的兼容性問題。 就我而言,問題是我安裝了pywin32-219.win- amd64 -py2.7而不是pywin32-py2.7.exe。
感謝所有閱讀或回答我的問題的人
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.