Search code examples
pythonpython-3.xtweepydata-analysis

Issue using Tweepy to pull data from Twitter Stream: Data Analysis


from tweepy import OAuthHandler
from tweepy import StreamListener

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=["car"])

The error I am getting is twitterStream = Stream(auth, listener()) NameError: name 'Stream' is not defined. This example is from the pythonprogramming.net website. I am not sure what I am to assign to 'Stream'. I removed my authentication tokens and others from this but do have them.


Solution

  • from tweepy import Stream

    This will fix the issue.