tweepy错误。方法不存在

时间:2012-09-08 17:44:38

标签: python twitter tweepy

我需要运行twitter api调用友情查询。电话的详细信息如下:

https://dev.twitter.com/docs/api/1.1/get/friendships/lookup

我使用tweepy在python中执行此操作,但是,它根本不存在于tweepy中。我做了一点挖掘,发现这个方法已添加到tweepy,我有最新版本。检查一下:

https://github.com/tweepy/tweepy/commit/aa055fe16c73f80a0a36279bfc83e40af3d93008

每当我尝试运行api.lookup_friendship时。它在代码中不存在。我能用这种方式工作吗?

1 个答案:

答案 0 :(得分:1)

August 19th之后的1.11 release was cut (on August 14th 2012)之前,您链接到的提交未与tweepy主分支合并。在1.12出现之前,您需要直接从git安装才能获得此功能。 *

要使用pip安装当前开发版本,请使用:

pip install -e git+https://github.com/tweepy/tweepy.git#egg=tweepy

运行该命令后,可以使用.lookup_friendships()方法:

>>> import tweepy
>>> api = tweepy.API()
>>> api.lookup_friendships
<bound method API.lookup_friendships of <tweepy.api.API object at 0x10a7ad290>>
>>> api.lookup_friendships()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/private/tmp/tweepy/src/tweepy/tweepy/api.py", line 285, in lookup_friendships
    return self._lookup_friendships(list_to_csv(user_ids), list_to_csv(screen_names))
  File "/private/tmp/tweepy/src/tweepy/tweepy/binder.py", line 184, in _call
    method = APIMethod(api, args, kargs)
  File "/private/tmp/tweepy/src/tweepy/tweepy/binder.py", line 34, in __init__
    raise TweepError('Authentication required!')
tweepy.error.TweepError: Authentication required!

我没有打扰登录;不过,上述演示确实表明它有效。 : - )


* 版本1.12,包括此更改,于2012年11月8日发布。