【发布时间】:2018-11-04 06:37:05
【问题描述】:
我正在尝试使用 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 导入 Stream,StreamListener 文件“C:\Users\joshey\AppData\Local\Programs\Python\Python37\lib\site-packages\tweepy\streaming.py”,第 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安装或代码有问题吗? 谁能帮我找出问题所在? 提前致谢。
【问题讨论】:
-
奇怪的是
def _start(self, async)不在代码库中,它是def _start(self, is_async)。 3.7从哪里得到前一种方法? -
在我查看源代码时,已将修复问题的 18dad6f 提交到 master 中。
pip install -U git+https://github.com/tweepy/tweepy.git在正式发布修正错误之前有效。
标签: python-3.x tweepy python-3.7