13

I get App Engine from https://cloud.google.com/sdk/docs/
After install, I cant run gsutil init or gcloud info --run-diagnostics in Google Clood SDK Shell or Windows Powershell, it ends with this error:

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

I had UTF-8 set as the encoding:

[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

I've tried all this answers, but it didn't help → gsutil command crashes every time on Windows 10, LookupError: unknown encoding: cp0, Python 2.7 : LookupError: unknown encoding: cp65001

I've tried install Python 3.7, 2.7.9 and "Bundled Python".

5 Answers5

27

You can try running:

set PYTHONIOENCODING=UTF-8

Or, create an environment variable with the name 'PYTHONIOENCODING' and value 'UTF-8'.

It solves the problem for me.

Jee Mok
  • 6,157
  • 8
  • 47
  • 80
20

I had the exact same problem on Windows 10 and remembered that before Google Cloud installation I had enabled Unicode UTF-8 for worldwide support and disabling that beta feature resolved the issue.

To disable it:

  • Open Region & language settings (press WinKey and type: region)
  • In Related settings section click Administrative language settings
  • On the Administrative tab click Change system locale...
  • Be sure to uncheck Beta: Use Unicode UTF-8 for worldwide language support

Try reinstalling Google Cloud SDK and after execute in command line gcloud init again, should work.

Update

This solution considers that you’re using a native shell. If it’s not the case then please try the solution of @jee-mok.

kuza
  • 2,761
  • 3
  • 22
  • 56
2

You simply need to make reconnection with Google cloud shell. Reopen Google Cloud SDK Shell

gcloud init

it will ask for new configuration or use an existing one, I used existing one then select account select project on cloud which you want to work.

1

My solution was to issue the deploy via a separate powershell window and not the one embedded in Visual Studio Code. Possibly VS Code alters the UTF page settings of the embedded terminal.

BTW, I was deploying a nodeJS app, not a python app.

Erik Bongers
  • 416
  • 2
  • 10
  • This was the solution that worked for me. I was following the steps in the accepted answer and found that my "Beta: Use Unicode UTF-8 for worldwide language support" was already unchecked. Then, I read this and realized I was also using the integrated VS Code terminal. Using a separate Windows terminal to run my gcloud commands instead worked. – Matt Welke Mar 01 '20 at 22:46
0

I have experienced the same also when I run that command inside vscode terminal, but when I open another cmd and run the same command everything works perfectly maybe the vscode default terminal is windows powershell

EleaCode
  • 139
  • 1
  • 4