执行Python出现LookupError: unknown encoding: cp65001解决办法

在执行fetch v8时出现

E:GitProjectsvn_v8>fetch v8
Running: E:GitProjectlibcefdepot_toolspython276_binpython.exe E:GitProj
ectlibcefdepot_toolsgclient.py root
Traceback (most recent call last):
  File "E:GitProjectlibcefdepot_tools\fetch.py", line 353, in <module>
    sys.exit(main())
  File "E:GitProjectlibcefdepot_tools\fetch.py", line 348, in main
    return run(options, spec, root)
  File "E:GitProjectlibcefdepot_tools\fetch.py", line 342, in run
    return checkout.init()
  File "E:GitProjectlibcefdepot_tools\fetch.py", line 134, in init
    self.run_gclient(config, --spec, self._format_spec())
  File "E:GitProjectlibcefdepot_tools\fetch.py", line 76, in run_gclient
    return self.run(cmd_prefix + cmd, **kwargs)
  File "E:GitProjectlibcefdepot_tools\fetch.py", line 63, in run
    print Running: %s % ( .join(pipes.quote(x) for x in cmd))
LookupError: unknown encoding: cp65001

LookupError: unknown encoding: cp65001

出现此错误后改变编码方式即可解决:

chcp 1252

也可以通过修改注册表CodePage值来设置默认字符编码 HKEY_CURRENT_USERConsole\%SystemRoot%_system32_cmd.exeCodePage

经验分享 程序员 微信小程序 职场和发展