Tweepy streaming error

2019-07-17 07:26发布

问题:

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.

回答1:

"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 :)



回答2:

Replacing async with async_ Did the trick for me.

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



回答3:

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