title: TypeError: sequence item 1:expected str instance, bytes found
body: <p>I want to download tweets from twitter as data sets for sentiment analysis using Python Twitter API ..</p>
  <p>I am using SemEval 2016 task 6 dataset ..So I downloaded &quot;<a href="http://alt.qcri.org/semeval2016/task6/data/uploads/semeval2016-task6-domaincorpus.zip" rel="nofollow noreferrer">Domain corpus for task B</a>&quot; and I found a Readme file that describe the steps ..</p>
  <p>I am just a beginner and I do not know much in python ..I installed python 3.4.3 and I already found easy_install.exe and pip.exe in scripts folder ..</p>
  <p>I typed in cmd :  &quot;easy_install twitter&quot; as it is written in readme file ...then I tried to apply the steps from Readme file , here are the steps:</p>
  <blockquote>
  <p>The first time you run this, it should open up a web browser, have you log into</p>
  <p>Twitter, and show a PIN number for you to enter into a prompt generated by the</p>
  <p>script.</p>
  <ol>
  <li><p>Login to Twitter with your user name in your <em>default</em> browser.</p>
  </li>
  <li><p>Run the script like this to download your credentials: <code>python download_tweets_api.py --dist=Donald_Trump.txt -- output=downloaded_Donald_Trump.txt</code></p>
  </li>
  <li><p>Download tweets like so: <code>python download_tweets_api.py --dist=Donald_Trump.txt --output=downloaded_Donald_Trump.txt</code></p>
  </li>
  </ol>
  </blockquote>
  <p>I finished step 1 , then I typed in cmd &quot;download_tweets_api.py --dist=Donald_Trump.txt --output=downloaded_Donald_Trump.txt&quot; but I got an error in last line of the file</p>
  <p><strong>TypeError: sequence item 1:expected str instance, bytes found</strong></p>
  <p>Here is the content of the file &quot;download_tweets_api.py&quot;</p>
  <pre><code>import sys
  import os
  import time
  import datetime
  import argparse
  from twitter import *
  
  parser = argparse.ArgumentParser(description=&quot;downloads tweets&quot;)
  parser.add_argument('--partial', dest='partial', default=None, type=argparse.FileType('r'))
  parser.add_argument('--dist', dest='dist', default=None, type=argparse.FileType('r'), required=True)
  parser.add_argument('--output', dest='output', default=None,type=argparse.FileType('w'), required=True)
  args = parser.parse_args()
  
  
  CONSUMER_KEY='xxxxxxxxxxx'
  CONSUMER_SECRET='xxxxxxxxxxxxxxxxx'
  
  MY_TWITTER_CREDS = os.path.expanduser('~/.my_app_credentials')
  if not os.path.exists(MY_TWITTER_CREDS):
  oauth_dance(&quot;Semeval sentiment analysis&quot;, CONSUMER_KEY, CONSUMER_SECRET, MY_TWITTER_CREDS)
  oauth_token, oauth_secret = read_token_file(MY_TWITTER_CREDS)
  t = Twitter(auth=OAuth(oauth_token, oauth_secret, CONSUMER_KEY, CONSUMER_SECRET))
  
  cache = {}
  if args.partial != None:
      for line in args.partial:
          fields = line.strip().split(&quot;\t&quot;)
          text = fields[-1]
          sid = fields[0]
          cache[sid] = text
  
  for line in args.dist:
      fields = line.strip().split('\t')
      sid = fields[0]
  
      while not sid in cache:
          try:
              text = t.statuses.show(_id=sid)['text'].replace('\n', '  ').replace('\r', ' ')
              cache[sid] = text.encode('utf-8')
          except TwitterError as e:
              if e.e.code == 429:
                  rate = t.application.rate_limit_status()
                  reset = rate['resources']['statuses']['/statuses/show/:id'] ['reset']
                  now = datetime.datetime.today()
                  future = datetime.datetime.fromtimestamp(reset)
                  seconds = (future-now).seconds+1
                  if seconds &lt; 10000:
                      sys.stderr.write(&quot;Rate limit exceeded, sleeping for %s  seconds until %s\n&quot; % (seconds, future))
                      time.sleep(seconds)
              else:
                  cache[sid] = 'Not Available'
  
      text = cache[sid]
  
      args.output.write(&quot;\t&quot;.join(fields + [text]) + '\n')
  </code></pre>
  <p>Note you can find the download_tweets_api.py and readme files in the &quot;<a href="http://alt.qcri.org/semeval2016/task6/data/uploads/semeval2016-task6-domaincorpus.zip" rel="nofollow noreferrer">domain corpus for task B</a>&quot;</p>