Yogitha Ch
Yogitha Ch

Reputation: 21

Tweepy to access Twitter streaming API using python 3.4

I'm unable to use tweepy to access Twitter streaming API using the following example code using python 3.4. This code was running using python 2.4. What is wrong ?

from tweepy import Stream
from tweepy import OAuthHandler
from tweepy.streaming import StreamListener


ckey = ''
csecret = ''
atoken = ''
asecret = ''

class listener(StreamListener):

    def on_data(self, data):
        print (data)
        return True

    def on_error(self, status):
        print (status)

auth = OAuthHandler(ckey, csecret)
auth.set_access_token(atoken, asecret)
twitterStream = Stream(auth, listener())
twitterStream.filter(track=["obama"])

Upvotes: 0

Views: 324

Answers (1)

Nishant Nawarkhede
Nishant Nawarkhede

Reputation: 8400

Your code is exactly correct.

But on Windows Vista/7, with UAC, administrator accounts run programs in unprivileged mode by default. Or it might be possible that you are trying to run on a port the current user account does not have permission to bind to. Run the following code to detect your script has admin access or not.

import ctypes
print ctypes.windll.shell32.IsUserAnAdmin()

If it prints 1 then its ok. If 0 then your script doesn't have admin access.

Upvotes: 1

Related Questions