问题
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