Skip to content Skip to sidebar Skip to footer

Changing The Preferred Encoding For Windows7 Command Prompt

Using Python3.3 Running a python script to do some CAD file conversion, but getting below error Conversion Failed Traceback (most recent call last): File 'Start.py', line 141, in c

Solution 1:

When writing to files, the console encoding is not taken into account; only the locale is. From the open() function documenation:

In text mode, if encoding is not specified the encoding used is platform dependent: locale.getpreferredencoding(False) is called to get the current locale encoding.

On your system, evidently that call returns 'cp1252'. The remedy is to always name the encoding for files explicitly; pass in an encoding argument to set the desired encoding for files:

withopen(filename, 'w', encoding='utf8') as symFile:

Post a Comment for "Changing The Preferred Encoding For Windows7 Command Prompt"