import sys
import imp
try:
    sys.setappdefaultencoding('utf-8')
except:
    sys = imp.reload(sys)
sys.setdefaultencoding('utf-8')
Peter Piper piped a Python program - and lost all his unicode characters