Python Tweepy流错误:\uuuu init\uuuuuu()正好接受3个参数(给定4个)

Python Tweepy流错误:\uuuu init\uuuuuu()正好接受3个参数(给定4个),python,twitter,tweepy,Python,Twitter,Tweepy,我试图使用Tweepy python api创建twitter搜索流,但我遇到了一个错误。下面是我试图执行的代码和我得到的错误-> File "code.py", line 28, in <module> stream = Stream(auth, x, "microsoft") __init__() takes exactly 3 arguments (4 given) 问题在于流初始化线: stream = Stream(auth, x, "microsoft") 那

我试图使用Tweepy python api创建twitter搜索流,但我遇到了一个错误。下面是我试图执行的代码和我得到的错误->

File "code.py", line 28, in <module>
    stream = Stream(auth, x, "microsoft")
__init__() takes exactly 3 arguments (4 given)

问题在于流初始化线:

stream = Stream(auth, x, "microsoft")
那应该是

stream = Stream(auth, x)
跟踪词不是通过构造函数传递的,而是通过
过滤器
方法传递的。

Stream()
只接受2个参数(加上绑定方法的
self
):

参见Tweepy项目给出的示例

307重定向可能不应作为错误处理;您可以通过从
on\u error
处理程序返回
True
来告诉Tweepy继续:

def on_error(self, status):
    print status
    if status == 307:
        return True

您确定错误是按照您提供的方式给出的,
\u init\u
,而不是
\u init\u
?它是双下划线…我懒得键入它。对不起@PreritAhuja:不要键入错误消息;复制并粘贴它。当然从现在开始…我用的是一个愚蠢的控制台。对不起,Windows控制台有复制功能;使用窗口菜单允许您“标记”进行选择,然后使用“复制”复制所选文本。非常隐藏,但这是Microsoft为您准备的。我得到了这个错误------文件“\twittersearch\u v3.py”,第30行,响应=stream.filter(track=['Microsoft'])文件“build\bdist.win32\egg\tweepy\streaming.py”,第242行,在过滤器文件“build\bdist.win32\egg\tweepy\streaming.py”的第181行,在启动文件中“build\bdist.win32\egg\tweepy\streaming.py”,第120行,在运行ttributeError时:“str”对象没有“on_error”@PreritAhuja您得到http 307或AtributeError吗?如果是后者,您可能离开了“microsoft”而不是x。如果是第一行,那么您的tweepy可能太旧了,请检查tweepy版本是否早于2.0这是我正在使用的版本{x=StdOutListener()stream=stream(auth,x)response=stream.filter(track=['microsoft'])print response}刚刚得到“307”。它没有说任何其他内容,我使用的是tweepy 2.1
stream = Stream(auth, x)
stream.filter(track=['microsoft'])
def on_error(self, status):
    print status
    if status == 307:
        return True