Google Cloud App SDK 崩溃 → 云崩溃(LookupError):未知编码 cp65001

Google Cloud App SDK crash → cloud crashed (LookupError): unknown encoding cp65001

我从 https://cloud.google.com/sdk/docs/ 获取 App Engine
安装后,我无法在 Google Clood SDK Shell 或 Windows Powershell 中 运行 gsutil initgcloud info --run-diagnostics,它以此错误:

Welcome! This command will take you through the configuration of gcloud.

Your current configuration has been set to: [default]

You can skip diagnostics next time by using the following flag:
  gcloud init --skip-diagnostics

Network diagnostic detects and fixes local network connection issues.
ERROR: gcloud crashed (LookupError): unknown encoding: cp65001

If you would like to report this issue, please run the following command:
  gcloud feedback

To check gcloud for common problems, please run the following command:
  gcloud info --run-diagnostics

我将 UTF-8 设置为编码:

[Console]::OutputEncoding
BodyName          : utf-8
EncodingName      : Unicode (UTF-8)
HeaderName        : utf-8
WebName           : utf-8
WindowsCodePage   : 1200
IsBrowserDisplay  : True
IsBrowserSave     : True
IsMailNewsDisplay : True
IsMailNewsSave    : True
IsSingleByte      : False
EncoderFallback   : System.Text.EncoderReplacementFallback
DecoderFallback   : System.Text.DecoderReplacementFallback
IsReadOnly        : True
CodePage          : 65001

我已经尝试了所有这些答案,但没有帮助 → LookupError: unknown encoding: cp0,

我试过安装 Python 3.7、2.7.9 和 "Bundled Python"。

我在 Windows 10 上遇到了完全相同的问题,记得在 Google 云安装之前,我启用了 Unicode UTF-8 以获得全球支持并禁用该测试版功能解决了这个问题。

要禁用它:

  • 打开区域和语言设置(按WinKey并输入:地区
  • 相关设置部分点击管理语言设置
  • 管理 选项卡上单击更改系统区域...
  • 务必取消选中 Beta:使用 Unicode UTF-8 以获得全球语言支持

尝试重新安装 Google Cloud SDK 并在命令行 gcloud init 中再次执行后,应该可以工作。

更新

此解决方案认为您使用的是原生 shell。如果不是这样,请尝试@jee-mok.

你可以试试运行:

set PYTHONIOENCODING=UTF-8

或者,使用名称 'PYTHONIOENCODING' 和值 'UTF-8' 创建一个环境变量。

它解决了我的问题。

您只需重新连接 Google 云 shell。 重新打开 Google Cloud SDK Shell

gcloud init

它会要求新配置或使用现有配置,我使用现有配置 然后 select 帐户 select 你想工作的云端项目。

我的解决方案是通过 单独的 powershell window 而不是嵌入在 Visual Studio 代码中的那个来发布部署。可能 VS Code 更改了嵌入式终端的 UTF 页面设置。

顺便说一句,我正在部署一个 nodeJS 应用程序,而不是 python 应用程序。

当我 运行 在 vscode 终端中执行该命令时,我也遇到了同样的情况,但是当我打开另一个 cmd 和 运行 相同的命令时,一切正常,也许 vscode 默认终端是 windows powershell