title: UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 118374: ordinal not in range(128)
body: <p>I am experimenting with some NLP algorithms and I am focusing now on sentiment analysis. For this reason, I downloaded from <a href="http://www.cs.jhu.edu/~mdredze/datasets/sentiment/index2.html" rel="nofollow noreferrer">http://www.cs.jhu.edu/~mdredze/datasets/sentiment/index2.html</a> some <code>.review</code> format files with positive and negative reviews. </p>
  
  <p>I am using <code>BeautifulSoup</code> for parsing these XML files and for now I am only trying to read them by executing the following source code:</p>
  
  <pre><code>from bs4 import BeautifulSoup
  
  positive_reviews = BeautifulSoup(open('*******/electronics/positive.review').read())
  positive_reviews = positive_reviews.findAll('review_text')
  
  negative_reviews = BeautifulSoup(open('*******/electronics/negative.review').read())
  negative_reviews = negative_reviews.findAll('review_text')
  </code></pre>
  
  <p>However, I am getting the following error:</p>
  
  <pre><code>UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 118374: ordinal not in range(128)
  </code></pre>
  
  <p>when</p>
  
  <pre><code>positive_reviews = BeautifulSoup(open('*******/electronics/positive.review').read())
  </code></pre>
  
  <p>is to be executed.</p>
  
  <p>How can I fix this error?</p>
  
  <p>I have also replaced</p>
  
  <pre><code>BeautifulSoup(open('*******/electronics/positive.review').read())
  </code></pre>
  
  <p>with</p>
  
  <pre><code>BeautifulSoup(open('*******/electronics/positive.review').read().decode('utf-8'))
  </code></pre>
  
  <p>but I am getting exactly the same error.</p>
  
  <p>Finally, I have already read some relevant posts on StackOverflow but so far nothing worked for me. For example, at my terminal <code>echo $LANG</code> outputs <code>en_GB.UTF-8</code>  as it is described at the first answer of <a href="https://stackoverflow.com/questions/10561923/unicodedecodeerror-ascii-codec-cant-decode-byte-0xef-in-position-1">UnicodeDecodeError: &#39;ascii&#39; codec can&#39;t decode byte 0xef in position 1</a> but I am still getting the error above.</p>