encoding - Change Windows 8 codepage in Python 3 Spyder console from cp1252 to utf-8 -
how 1 alter windows 8 codepage in python 3 spyder console cp1252 utf-8?
the code page apparently cp1252 evidenced
import locale locale.getpreferredencoding()
this means hard print non-ascii characters 'print' exception raised (unicodeencodeerror
).
one possible solution .encode method , 'errors' argument.
u'\x9d'.encode('cp1252', errors='replace')
but why isn't there (or the) alternative alter console encoding utf-8. expecting alternative in 'preferences'.
another solution execute python file outside spyder like:
chcp 65001 c:\path_to_python\python.exe the_script.py
this works lacks integratedness of spyder.
i tried create batch file with
chcp 65001 c:\path_to_python\python.exe
and set "use next python interpreter" in "advanced settings", spyder not allow - @ to the lowest degree way tried it.
i neither create workaround working making batch script with:
chcp 65001 c\:path_to_spyder\spyder.exe
(spyder dev here) fixed in our next release (i.e. version 2.3.2). both input , output in console treated unicode release onwards, python 3 , python 2 well.
python encoding windows-8 utf-8 spyder
No comments:
Post a Comment