3
votes

I'm trying to analyze the sentiment of the tweets using tweepy and textblob. I did pip install tweepy and it was installed successfully, but I get the following error.

Error Message: File "C:\Users\joshey\Desktop\sent.py", line 2, in import tweepy File "C:\Users\joshey\AppData\Local\Programs\Python\Python37\lib\site-packages\tweepy__init__.py", line 17, in from tweepy.streaming import Stream, StreamListener File "C:\Users\joshey\AppData\Local\Programs\Python\Python37\lib\site-packages\tweepy\streaming.py", line 355 def _start(self, async):

import tweepy
from textblob import TextBlob

consumer_key= 'CONSUMER_KEY_HERE'
consumer_secret= 'CONSUMER_SECRET_HERE'

access_token='ACCESS_TOKEN_HERE'
access_token_secret='ACCESS_TOKEN_SECRET_HERE'

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

api = tweepy.API(auth)

public_tweets = api.search('Trump')

for tweet in public_tweets:
print(tweet.text)

analysis = TextBlob(tweet.text)
print(analysis.sentiment)
print("")

Is there any problem with the tweepy installation or the code? Can anyone help me figure out what's the problem? I tried googling, but nothing worked. Thanks in advance.

Is there any problem with the tweepy installation or the code? Can anyone help me figure out what's the problem? Thanks in advance.

3
Strange thing is def _start(self, async) is nowhere in the codebase, it's def _start(self, is_async). Where is 3.7 getting the former method from? - belteshazzar
Commit 18dad6f that fixed the issue had already been merged into master by the time I was looking at the source. pip install -U git+https://github.com/tweepy/tweepy.git works, before they make a formal release with the bugfix. - belteshazzar

3 Answers

2
votes

"pip install tweepy" is still not currently functioning with python 3.7, roll back to 3.6.OB1 (and ignore the pip update recommendations).

should work then :)

0
votes

Replacing async with async_ Did the trick for me.

Ref: https://github.com/tweepy/tweepy/issues/1017

0
votes

Replacing async with async_ worked as stated by user10459541.

Just open the streaming.py file in the Lib\site-packages\tweepy path and replace all occurences with Find&Replace function on Notepad