From a5cfcb93ffbe52fef49ecdcfd1ce01974799694e Mon Sep 17 00:00:00 2001 From: Tan SU Date: Mon, 18 Apr 2022 17:27:22 +0800 Subject: [PATCH] [Fix] Get correct encoding in Windows for collect_env() (#1887) * [Fix] get correct encoding in Windows for collect_env() * stdout.fileno() --- mmcv/utils/env.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mmcv/utils/env.py b/mmcv/utils/env.py index cbacb6047..8b8c3628e 100644 --- a/mmcv/utils/env.py +++ b/mmcv/utils/env.py @@ -81,13 +81,13 @@ def collect_env(): # on Windows, cl.exe is not in PATH. We need to find the path. # distutils.ccompiler.new_compiler() returns a msvccompiler # object and after initialization, path to cl.exe is found. - import locale + import os from distutils.ccompiler import new_compiler ccompiler = new_compiler() ccompiler.initialize() cc = subprocess.check_output( f'{ccompiler.cc}', stderr=subprocess.STDOUT, shell=True) - encoding = locale.getdefaultlocale()[1] + encoding = os.device_encoding(sys.stdout.fileno()) or 'utf-8' env_info['MSVC'] = cc.decode(encoding).partition('\n')[0].strip() env_info['GCC'] = 'n/a' except subprocess.CalledProcessError: