【问题标题】:Tweepy streaming errorTweepy 流式传输错误
【发布时间】: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


【解决方案1】:

“pip install tweepy”目前仍然无法在 python 3.7 中运行,回滚到 3.6.OB1(并忽略 pip 更新建议)。

然后应该工作:)

【讨论】:

    【解决方案2】:

    async_ 替换async 对我有用。

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

    【讨论】:

      【解决方案3】:

      按照 user10459541 的说明,将 async 替换为 async_ 即可。

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

      【讨论】:

        猜你喜欢
        • 2015-12-13
        • 2017-10-16
        • 2021-03-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-01-22
        • 2022-06-15
        • 2018-06-23
        相关资源
        最近更新 更多