Tweepy: Invalid arguments at function call (tweepy.Stream())

Terry Reedy tjreedy at udel.edu
Mon Oct 31 17:32:04 EDT 2011


On 10/31/2011 12:18 PM, Ricardo Mansilla wrote:
> Hi i'm trying to fetch realtime data from twitter using tweepy.Stream().

A reference to your source for tweepy would help.
The link below gives https://github.com/tweepy/tweepy
for the current source.
http://pypi.python.org/pypi/tweepy/1.7.1
has versions for 2.4,5,6 from May 2010.
You neglected to mention which version of Python you are using

> streaming_api = tweepy.streaming.Stream(auth, CustomStreamListener(),
> timeout='90')
> and:
> streaming_api = tweepy.streaming.Stream(auth, CustomStreamListener(),
> timeout='90')

These look identical.

> none of this works, it keeps giving me the same error:
>
> Traceback (most recent call last):
> File "", line 1, in
> streaming_api = tweepy.streaming.Stream(auth, CustomStreamListener(),
> timeout='60')
> TypeError: *init*() takes at least 4 arguments (4 given)

3.2 prints the proper method name: __init__. I do not remember that 
older versions did that conversion, but maybe so. In any case, the error 
message us screwed up. It has been improved in current Python.

> then i have searched for the parameters of the function:
>
> tweedy.streaming.Stream(login,password,Listener(),...etc)
> but i thought this login and pass was the authentication method using in
> the basic authentication not in the oauth case.
> Now i'm really confused, a little help please?

The current tweepy/streaming.py source code from the site above says:

class Stream(object):
     def __init__(self, auth, listener, **options):
         self.auth = auth
         self.listener = listener
         self.running = False
         self.timeout = options.get("timeout", 300.0)
         <etc>

According to this, __init__ takes 3 positional params, which is what you 
gave it. Perhaps, this was different in an earlier version. Look at the 
code you are running.

> i have chose tweepy because the
> dev.twitter.com <http://dev.twitter.com> page recommended it,

That page mentions no libraries. Perhaps you meant
https://dev.twitter.com/docs/twitter-libraries

-- 
Terry Jan Reedy




More information about the Python-list mailing list