'Wit' 对象没有属性 'message'
'Wit' object has no attribute 'message'
只是尝试使用 Wit.ai & Python 进行试验,但出现以下错误。我在这里做错了什么??
错误:
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'
代码:
from wit import Wit
access_token='B3GHXHLTXIASO7S4KY7UC65LMSTCDEHK'
client = Wit(access_token)
my_message='who are you?'
resp = client.message(my_message)
print(resp)
所以,您似乎使用的是旧版本(实际上 unofficial) version of the Python pywit
package, last updated on 2015-11-07 (version 0.4.0)。
您应该删除 pywit
软件包并安装 wit
,就像他们在 docs/install 部分中所说的那样:
pip uninstall pywit
pip install wit
只是为了完整起见,如果您查看旧 pywit
包的 wit.py
内部,在 python2.7/site-packages/wit/wit.py
内部,您会看到旧 Wit
的定义class,使用 get_message()
方法代替当前的 message()
。因此,在 pywit
中,如果您说:
,您的代码将 运行
resp = client.get_message(my_message)
而不是
resp = client.message(my_message)
但你真的应该切换到当前(官方)版本。
只是尝试使用 Wit.ai & Python 进行试验,但出现以下错误。我在这里做错了什么??
错误:
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'
代码:
from wit import Wit
access_token='B3GHXHLTXIASO7S4KY7UC65LMSTCDEHK'
client = Wit(access_token)
my_message='who are you?'
resp = client.message(my_message)
print(resp)
所以,您似乎使用的是旧版本(实际上 unofficial) version of the Python pywit
package, last updated on 2015-11-07 (version 0.4.0)。
您应该删除 pywit
软件包并安装 wit
,就像他们在 docs/install 部分中所说的那样:
pip uninstall pywit
pip install wit
只是为了完整起见,如果您查看旧 pywit
包的 wit.py
内部,在 python2.7/site-packages/wit/wit.py
内部,您会看到旧 Wit
的定义class,使用 get_message()
方法代替当前的 message()
。因此,在 pywit
中,如果您说:
resp = client.get_message(my_message)
而不是
resp = client.message(my_message)
但你真的应该切换到当前(官方)版本。