Google Cloud SDK安装错误:UnicodeDecodeError:' ascii'编解码器不能解码位置197中的字节0xe2:序数不在范围内(128)

时间:2018-05-23 10:42:26

标签: google-cloud-platform google-cloud-sdk

Google Cloud SDK安装过程在我的计算机(MAC)上失败,并让我跟踪堆栈跟踪。

Traceback (most recent call last):
  File "/Users/ttn/Desktop/google-cloud-sdk/bin/bootstrapping/install.py", line 218, in <module>
    main()
  File "/Users/ttn/Desktop/google-cloud-sdk/bin/bootstrapping/install.py", line 203, in main
    sdk_root=bootstrapping.SDK_ROOT,
  File "/Users/ttn/Desktop/google-cloud-sdk/lib/googlecloudsdk/core/platforms_install.py", line 452, in UpdateRC
    completion_update, path_update, rc_path, sdk_root, host_os).Update()
  File "/Users/ttn/Desktop/google-cloud-sdk/lib/googlecloudsdk/core/platforms_install.py", line 214, in Update
    self.path, rc_contents, source_line=self._GetSourceLine())
  File "/Users/ttn/Desktop/google-cloud-sdk/lib/googlecloudsdk/core/platforms_install.py", line 167, in _GetRcContents
    filtered_contents=filtered_contents, line=line)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 197: ordinal not in range(128)

以下是更多细节:

系统的默认python版本

python -V
Python 3.6.1 :: Anaconda custom (x86_64)

Cloud SDK的Python版本。

echo $CLOUDSDK_PYTHON
/usr/bin/python2.7

检查gcloud命令

gcloud
-bash: gcloud: command not found

注意:这个问题可能看似重复,但我尝试在门户网站上提供的解决方案很少,但对我来说没有任何效果。

1 个答案:

答案 0 :(得分:2)

有一个解决此问题的公开拉取请求可以解决此问题。问题是其中一个文件包含非ASCII字符,导致Google Cloud SDK安装程序失败。 Python 2.7中的open()函数不允许指定的编码。

修复:
所有open()的引用都应替换为io.open(..., encoding='utf-8')。再次检查拉取请求以查看这些更改。

资源:
  - https://github.com/google-cloud-sdk/google-cloud-sdk/pull/2/files