Ubuntu 16.04 初始化GCP SDK出现错误 'ascii' codec can't decode的解决

日前,在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
    原文作者:empires2
    原文地址: https://www.jianshu.com/p/2f751f370598
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞