TypeError: Can't convert 'bytes' object to str implicitly for tweepy
Question: 
    from tweepy import Stream
    from tweepy import OAuthHandler
    from tweepy.streaming import StreamListener
    
    ckey=''
    csecret=''
    atoken=''
    asecret=''
    
    class listener(StreamListener):
    
        def on_data(self,data):
            print(data)
            return True
    
        def on_error(self,status):
            print(status)
    
    
    auth = OAuthHandler(ckey,csecret)
    auth.set_access_token(atoken, asecret)
    twitterStream = Stream(auth, listener())
    twitterStream.filter(track="cricket")
    

This code filter the twitter stream based on the filter. But I am getting
following traceback after running the code. Can somebody please help

    
    
    Traceback (most recent call last):
      File "lab.py", line 23, in <module>
        twitterStream.filter(track="car".strip())
      File "C:\Python34\lib\site-packages\tweepy\streaming.py", line 430, in filter
        self._start(async)
      File "C:\Python34\lib\site-packages\tweepy\streaming.py", line 346, in _start
        self._run()
      File "C:\Python34\lib\site-packages\tweepy\streaming.py", line 286, in _run
        raise exception
      File "C:\Python34\lib\site-packages\tweepy\streaming.py", line 255, in _run
        self._read_loop(resp)
      File "C:\Python34\lib\site-packages\tweepy\streaming.py", line 298, in _read_loop
        line = buf.read_line().strip()
      File "C:\Python34\lib\site-packages\tweepy\streaming.py", line 171, in read_line
    self._buffer += self._stream.read(self._chunk_size)
    TypeError: Can't convert 'bytes' object to str implicitly
    


Answer: Im assuming you're using tweepy 3.4.0. The issue you've raised is 'open' on
github (<https://github.com/tweepy/tweepy/issues/615>).

Two work-arounds :

**1)** In streaming.py:

I changed line 161 to

**self._buffer += self._stream.read(read_len).decode('UTF-8', 'ignore')**

and line 171 to

**self._buffer += self._stream.read(self._chunk_size).decode('UTF-8',
'ignore')**

and then reinstalled via python3 setup.py install on my local copy of tweepy.

**2)** remove the tweepy 3.4.0 module, and install 3.3.0 using command: **pip
install -I tweepy==3.3.0**

Hope that helps,

-A

