Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python TypeError:\uuuu init\uuuuu()至少接受4个非关键字参数(给定3个)_Python_Api_Streaming_Arguments - Fatal编程技术网

Python TypeError:\uuuu init\uuuuu()至少接受4个非关键字参数(给定3个)

Python TypeError:\uuuu init\uuuuu()至少接受4个非关键字参数(给定3个),python,api,streaming,arguments,Python,Api,Streaming,Arguments,可能重复: 当我使用此脚本时: import sys, tweepy, webbrowser Q = sys.argv[1:] class CustomStreamListener(tweepy.StreamListener): def on_status(self, status): try: print "%s\t%s\t%s\t%s" % (status.text,

可能重复:

当我使用此脚本时:

import sys, tweepy, webbrowser

Q = sys.argv[1:] 

class CustomStreamListener(tweepy.StreamListener):

    def on_status(self, status):       
        try:
            print "%s\t%s\t%s\t%s" % (status.text, 
                                      status.author.screen_name, 
                                      status.created_at, 
                                      status.source,)
        except Exception, e:
            print >> sys.stderr, 'Encountered Exception:', e
            pass
    def on_error(self, status_code):
        print >> sys.stderr, 'Encountered error with status code:', status_code
        return True # Don't kill the stream
    def on_timeout(self):
        print >> sys.stderr, 'Timeout...'
        return True 
streaming_api = tweepy.streaming.Stream(auth, CustomStreamListener(), timeout=60)

print >> sys.stderr, 'Filtering the public timeline for "%s"' % (' '.join(sys.argv[1:]),)

streaming_api.filter(follow=None, track=Q)
下面是一个错误:

Traceback (most recent call last):
  File "C:/Python26/test.py", line 65, in <module>
    streaming_api = tweepy.streaming.Stream(auth, CustomStreamListener(), timeout=60)
TypeError: __init__() takes at least 4 non-keyword arguments (3 given)
回溯(最近一次呼叫最后一次):
文件“C:/Python26/test.py”,第65行,在
streaming_api=tweepy.streaming.Stream(auth,CustomStreamListener(),超时=60)
TypeError:\uuuu init\uuuuu()至少接受4个非关键字参数(给定3个)
我该怎么办

streaming_api = tweepy.streaming.Stream(auth, CustomStreamListener(), timeout=60)

在这一行中,您需要分别使用
用户名、密码更改
auth
,或者更新到tweepy的最新版本。

是的,很抱歉,我发布了两次…当我更改并更新tweepy并运行它时:streaming\u api=tweepy.streaming.Stream('username',password',CustomStreamListener(),timeout=30)出现如下错误:筛选“”的公共时间线遇到错误,状态代码为:406超时。。。状态代码遇到错误:406状态代码遇到错误:406状态代码遇到错误:406这是另一个问题,我想你要么编辑并重新打开线程,要么发布另一个问题,顺便说一句,我真的对你提到的这个新问题一无所知。