"Wit"对象没有属性"message" [英] 'Wit' object has no attribute 'message'

查看:77
本文介绍了"Wit"对象没有属性"message"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只想尝试Wit.ai& Python,但出现以下错误.我在这里做错什么了吗?

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

错误:

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)

推荐答案

因此,似乎您使用的是旧版本(实际上 pywit程序包,最后更新于2015- 11-07(0.4.0版).

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).

您应该删除pywit软件包并安装wit,就像他们在 docs/install 部分:

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

pip uninstall pywit
pip install wit

为完整起见,如果您查看旧版pywit包的wit.py内,在python2.7/site-packages/wit/wit.py内,您会看到旧的Wit类的定义,使用的是get_message()方法,而不是当前的message().因此,在pywit中,如果您说:

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)

代替

resp = client.message(my_message)

但是您应该真正切换到当前(正式)版本.

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

这篇关于"Wit"对象没有属性"message"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆