Make sure you have latest version of tweepy installed.
In [7]:
pip install tweepy
Let us check the version of tweepy installed.
In [8]:
pip show tweepy
Let us see if we can use tweepy now.
In [3]:
import tweepy
In [5]:
auth = tweepy.OAuth1UserHandler(
consumer_key, consumer_secret, access_token, access_token_secret
)
api = tweepy.API(auth)
public_tweets = api.home_timeline()
for tweet in public_tweets:
print(tweet.text)
break
Ok so far so good, Let us try the api.search() method now.
In [6]:
for tweets in api.search(q="aapl", lang="en"):
print(tweets)
In tweepy 4.0.0 and above versions, api.search has been replaced with api.search_tweets()
In [11]:
tweets = api.search_tweets(q="aapl", lang="en")
In [17]:
len(tweets)
Out[17]: