日前,在Ubuntu16.04上安装Google Cloud Platfrom SDK后,对GCP gcloud进行初始化时,出现了如下错误:
czhcheng@ThinkCentre:~$ gcloud init
Welcome! This command will take you through the configuration of gcloud.
...
ERROR: gcloud crashed (UnicodeDecodeError): 'ascii' codec can't decode byte 0xbb in position 1: ordinal not in range(128)
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
经搜索后,发现错误出现在google-cloud-sdk/lib/third_party/socks/__init__.py
第262行
req = req + struct.pack(">H", destport)
改为:
if isinstance(req, unicode):
req = req.encode('UTF-8')
req = req + struct.pack(">H", destport)
之后,重新运行:
$ gcloud init
一切正常.
所用GCP SDK版本如下:
~$ gcloud version
Google Cloud SDK 191.0.0
bq 2.0.29
core 2018.02.23
gsutil 4.28