avoid a UnicodeError on windows with non-charmap characters
@@ -67,9 +67,10 @@ def _find_by_py_launcher(
) -> Optional[str]: # pragma: no cover (windows only)
if version.startswith('python'):
num = version[len('python'):]
- try:
cmd = ('py', f'-{num}', '-c', 'import sys; print(sys.executable)')
- return cmd_output(*cmd)[1].strip()
+ env = dict(os.environ, PYTHONIOENCODING='UTF-8')
+ try:
+ return cmd_output(*cmd, env=env)[1].strip()
except CalledProcessError:
pass
return None
