3

我正在尝试使用 tweepy 和 textblob 分析推文的情绪。我做了 pip install tweepy 并且它安装成功,但我收到以下错误。

错误消息:文件“C:\Users\joshey\Desktop\sent.py”,第 2 行,导入 tweepy 文件“C:\Users\joshey\AppData\Local\Programs\Python\Python37\lib\site-packages\ tweepy__init__.py”,第 17 行,从 tweepy.streaming 导入流,StreamListener 文件“C:\Users\joshey\AppData\Local\Programs\Python\Python37\lib\site-packages\tweepy\streaming.py”,行第355章

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安装或代码有什么问题吗?谁能帮我找出问题所在?提前致谢。

4

3 回答 3

2

“pip install tweepy”目前仍然无法与 python 3.7 一起使用,回滚到 3.6.OB1(并忽略 pip 更新建议)。

那么应该工作:)

于 2018-02-01T04:12:13.417 回答
0

替换为asyncasync_我有用。

参考:https ://github.com/tweepy/tweepy/issues/1017

于 2018-10-05T02:22:34.180 回答
0

如 user10459541 所述,将 async 替换为 async_ 即可。

只需打开 Lib\site-packages\tweepy 路径中的 streaming.py 文件,然后用记事本上的 Find&Replace 功能替换所有出现的地方

于 2018-11-03T22:37:05.240 回答