我正试图用tweepy和textblob来分析推文的情绪 . 我做了pip install tweepy并且安装成功,但是我收到以下错误 .
错误消息:文件“C:\ Users \ joshey \ Desktop \ sent.py”,第2行,导入文件“C:\ Users \ joshey \ AppData \ Local \ Programs \ Python \ Python37 \ lib \ site-packages \ tweepy__init__.py“,第17行,来自tweepy.streaming导入Stream,StreamListener文件”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("")
tweepy安装或代码有什么问题吗?任何人都可以帮我弄清问题是什么?我试过谷歌搜索,但没有任何效果 . 提前致谢 .
tweepy安装或代码有什么问题吗?任何人都可以帮我弄清问题是什么?提前致谢 .
3 回答
“pip install tweepy”目前仍然没有使用python 3.7,回滚到3.6.OB1(并忽略点子更新建议) .
应该工作然后:)
用
async_
替换async
为我做了诀窍 .参考:https://github.com/tweepy/tweepy/issues/1017
用async_替换async按照user10459541的说明工作 .
只需打开Lib \ site-packages \ tweepy路径中的streaming.py文件,并用记事本上的查找和替换功能替换所有出现的文件