具有Tweepy,TypeError的StreamListener

时间:2015-11-09 13:23:43

标签: python python-2.7 api twitter tweepy

我试图从特定的hastags中恢复推文。我使用Python 2.7.6和Tweepy来听一个hastag。在这篇文章之后:Introduction to tweepy, Twitter for Python我最终得到了:

from tweepy.streaming import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream

access_token = ""
access_token_secret = ""

consumer_secret = ""
consumer_key = ""


class StdOutListener(StreamListener):

    def on_status(self, status):
        # Prints the text of the tweet
        print('Tweet text: ' + status.text)


        return true

    def on_error(self, status_code):
        print('Got an error with status code: ' + str(status_code))
        return True # To continue listening

    def on_timeout(self):
        print('Timeout...')
        return True # To continue listening

if __name__ == '__main__':
    listener = StdOutListener()
    auth = OAuthHandler(consumer_key, consumer_secret)
    auth.set_access_token(access_token, access_token_secret)

    stream = Stream(auth, listener)
    stream.filter(track=['#apple'])

但是当我运行脚本时,我有以下错误:

  

文件" test.py",第40行,in       stream.filter(轨迹= ['#苹果'])     File" /Library/Python/2.7/site-packages/tweepy/streaming.py" ;,第430行,在过滤器中       self._start(异步)     文件" /Library/Python/2.7/site-packages/tweepy/streaming.py",第346行,在_start中       self._run()     文件" /Library/Python/2.7/site-packages/tweepy/streaming.py" ;,第286行,在_run       提出例外   TypeError:无法创建内存视图,因为对象没有缓冲区接口

有谁知道为什么?

1 个答案:

答案 0 :(得分:7)

这似乎是一个已知问题webgl-heatmap-leaflet

如果您将pip uninstall requests pip install requests==2.7 降级为2.7,则应解决此问题。

XValueMember