Thursday, April 16, 2015

Error Encoding with Python 3 on Windows Command Prompt


Error Encoding with Python 3 on Windows Command Prompt
Environment: MS Windows 7 / Python 3.4



I have do some script with Python 3, but the output is always contains some weird character, looks like error encoding, Python 3 is using unicode by default, Finally, I found that the problem is come from the Command Prompt, you must configure the code page of command prompt to ensure which is running with unicode.


Method to change the code page:
<command prompt>
#chcp 65001
then right click, <command prompt> , <properties> , change the font to something other than Raster
it will turn command prompt to using unicode UTF-8, the setting will be save once your run the command.

Thanks for watching