Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Cloud SDK installation error: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 197: ordinal not in range(128)

Google Cloud SDK installation process is failing on my machine(MAC) and giving me following stack trace.

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)

Here are few more details:

System's default python version

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

Python version for Cloud SDK.

echo $CLOUDSDK_PYTHON
/usr/bin/python2.7

Checking gcloud command

gcloud
-bash: gcloud: command not found

Note: This question might seem as duplicate, but i tried few solution available on portal but nothing worked for me.

like image 990
Gaurav Gupta Avatar asked May 23 '18 10:05

Gaurav Gupta


1 Answers

There is an open pull request to address this issue linked below that fixes the issue. The issue was that one of the files contain non-ASCII characters which causes the the Google Cloud SDK installer to fail. The open() function in Python 2.7 doesn't allow for a specified encoding.

Fix:
All references with open() should be replaced with io.open(..., encoding='utf-8'). Once again check the pull request to see those changes.

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

like image 134
dkroy Avatar answered Nov 13 '22 09:11

dkroy