You should consider removing sys.setdefaultencoding at this point as well. I'm assuming it is disabled by default for a good reason.