'Wit' object has no attribute 'message'

你说的曾经没有我的故事 提交于 2019-12-12 03:53:55

问题


Just trying to experiment with Wit.ai & Python but getting the following error. What am I doing wrong here??

Error:

Traceback (most recent call last):
File "C:/Python27/mx1.py", line 7, in <module>
resp = client.message(my_message)
AttributeError: 'Wit' object has no attribute 'message'

Code:

from wit import Wit
access_token='B3GHXHLTXIASO7S4KY7UC65LMSTCDEHK'
client = Wit(access_token)
my_message='who are you?'
resp = client.message(my_message)
print(resp)

回答1:


So, it seems like you're using an older (actually unofficial) version of the Python pywit package, last updated on 2015-11-07 (version 0.4.0).

You should remove the pywit package and install wit, just like they say in the docs/install section:

pip uninstall pywit
pip install wit

Just for completeness, if you look inside the wit.py of your older pywit package, inside your python2.7/site-packages/wit/wit.py, you'll see the definition of old Wit class, with a get_message() method instead of the current message(). So, in the pywit, your code will run if you say:

resp = client.get_message(my_message)

instead of

resp = client.message(my_message)

But you should really switch to the current (official) version.



来源:https://stackoverflow.com/questions/45121612/wit-object-has-no-attribute-message

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!