After struggling with encoding problems in a rows-rich code in sublime text 2, I decided to make a simpler experiment. I used the following code, trying to print in Chinese :
#!/usr/bin/env python # -*- coding: utf-8 -*- print('你好') When running in sublime text, I receive the following error:
File "D:\xampp\htdocs\stam\chinese print try.py", line 4, in <module> print('\u4f60\u597d') File "d:\Python34\lib\encodings\cp1252.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_table)[0] UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-1: character maps to <undefined> [Finished in 0.2s with exit code 1] And here is the big but. When I run the code through the regular Python GUI, everything's fine. It prints.
I tried looking here but didn't understand how it can help me (which could indeed be my lack of understanding in sublime text configuration).
Thanks for your kind help.
cp1252encoding. Is normal it yields an error since that encoding doesn't support chinese characters. You need to set a proper encoding for your console withchcpcommand.