title: glove = pickle.load(f) EOFError: Ran out of input
body: <p>So here:</p>
  
  <pre><code>glove_path = './embeddings/glove_{}_{}.pkl'.format(dataset,mode)
  if(os.path.isfile(glove_path)):
          print("Reusing glove dictionary to save time")
          #with open(glove_path,'r') as f:
          with open(glove_path, 'rb') as f: #python 3 for pickle byte size object is needed not str
                  glove = pickle.load(f)
          save = False
  </code></pre>
  
  <p>If I try</p>
  
  <pre><code>with open(glove_path,'r') as f:
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>Reusing glove dictionary to save time
  Traceback (most recent call last):
    File "prepare.py", line 315, in &lt;module&gt;
      glove = pickle.load(f)
  TypeError: a bytes-like object is required, not 'str'
  </code></pre>
  
  <p>and if I try </p>
  
  <pre><code>with open(glove_path, 'rb') as f: #python 3 for pickle byte size object is needed not str
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>Reusing glove dictionary to save time
  Traceback (most recent call last):
    File "prepare.py", line 315, in &lt;module&gt;
      glove = pickle.load(f)
  EOFError: Ran out of input
  </code></pre>
  
  <p>Can you please guide how to fix this?</p>
  
  <p>I am using the code from <a href="https://github.com/vanzytay/pytorch_sentiment_rnn" rel="nofollow noreferrer">https://github.com/vanzytay/pytorch_sentiment_rnn</a> and using <code>Anaconda Python 3.6</code>.</p>
  
  <p>I have imported pickle like </p>
  
  <pre><code>import six; from six.moves import cPickle as pickle #import compatability with Python 2 using six 
  </code></pre>
  
  <p>while it was originally imported as:</p>
  
  <pre><code>import cPickle as pickle #python 2
  </code></pre>