Try setting the system default encoding as utf-8 at the start of the script, so that all strings are encoded using that. Example - import sys reload(sys) sys.setdefaultencoding('utf-8') The above should set the default encoding as utf-8 . In most cases, the issue is that when you call str(), python uses the default character encoding to try and encode the bytes you gave it, which in your case are sometimes representations of unicode characters. To fix the problem, you have to tell python how to deal with the string you give it by using .encode('whatever_unicode'). Most of the time, you should be fine using utf-8. So, stop using str() to convert from unicode to encoded text / bytes, properly use .encode() to encode the string:, yourstring.encode('utf-8') For python 3.x ,there is default encoding, hence there will be no issue of encoding.
... View more