Receive error when I installing gcutil in MacOS
Asked Answered
T

4

7

I followed the instructions given by the official documents, but stuck in executing ./install.sh.

MacOS version:10.14.5 (18F132) Python version:python2.7

After I download the zip file given by the gcloud website, I run the command ./install.sh.It told me

weiziyangdeMacBook-Pro:google-cloud-sdk weiziyang$ ./install.sh
Welcome to the Google Cloud SDK!
ERROR:root:code for hash md5 was not found.
Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type md5
ERROR:root:code for hash sha1 was not found.
Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha1
ERROR:root:code for hash sha224 was not found.
Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha224
ERROR:root:code for hash sha256 was not found.
Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha256
ERROR:root:code for hash sha384 was not found.
Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha384
ERROR:root:code for hash sha512 was not found.
Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha512
Traceback (most recent call last):
  File "/Users/weiziyang/google-cloud-sdk/bin/bootstrapping/install.py", line 12, in <module>
    import bootstrapping
  File "/Users/weiziyang/google-cloud-sdk/bin/bootstrapping/bootstrapping.py", line 32, in <module>
    import setup  # pylint:disable=g-import-not-at-top
  File "/Users/weiziyang/google-cloud-sdk/bin/bootstrapping/setup.py", line 55, in <module>
    from googlecloudsdk.core import properties
  File "/Users/weiziyang/google-cloud-sdk/lib/googlecloudsdk/core/properties.py", line 27, in <module>
    from googlecloudsdk.core import config
  File "/Users/weiziyang/google-cloud-sdk/lib/googlecloudsdk/core/config.py", line 29, in <module>
    from googlecloudsdk.core.util import files as file_utils
  File "/Users/weiziyang/google-cloud-sdk/lib/googlecloudsdk/core/util/files.py", line 600, in <module>
    class Checksum(object):
  File "/Users/weiziyang/google-cloud-sdk/lib/googlecloudsdk/core/util/files.py", line 603, in Checksum
    def __init__(self, algorithm=hashlib.sha256):
AttributeError: 'module' object has no attribute 'sha256'

I checked the module of python2, it provided that I haved installed hashlib correctly and has the attribute 'sha256'

weiziyangdeMacBook-Pro:google-cloud-sdk weiziyang$ python2
Python 2.7.10 (default, Feb 22 2019, 21:55:15) 
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import hashlib
>>> hashlib.sha256
<built-in function openssl_sha256>
>>> exit()

I expect it can be installed correctly.

Tryst answered 23/7, 2019 at 12:55 Comment(0)
P
6

What worked for me was

  1. brew uninstall all openssl and python packages listed by brew list

  2. brew install python3

  3. sudo ln -s /usr/local/bin/python3 /usr/local/bin/python and sudo ln -s /usr/local/bin/pip3 /usr/local/bin/pip

  4. Installing gcloud with the Google Cloud SDK installer https://cloud.google.com/sdk/docs/downloads-interactive

Poinsettia answered 4/3, 2020 at 21:24 Comment(1)
encountered same issue after upgrading to macOS Catalina. The instructions above really helped!Unswear
A
2

This is what I've done Go to /usr/local/Cellar/ and remove all python folder except [email protected] then run ./install.sh again and then it will work.

Asphaltite answered 1/6, 2020 at 4:46 Comment(0)
A
0

The two Python versions you're using in the two examples above are different. The first Python you use is 2.7.15:

File "/usr/local/Cellar/python@2/2.7.15/...

And the second one is 2.7.10:

Python 2.7.10 (default, Feb 22 2019, 21:55:15)

It looks like your 2.7.15 installation of Python didn't install hashlib correctly (this can happen because of OpenSSL problems during installation, among other things). If I had to guess, the Cloud SDK install.sh script looks for a python executable, and python probably points to the broken 2.7.15 installation, while python2 probably points to the 2.7.10 installation on your system.

Accidental answered 23/7, 2019 at 19:2 Comment(0)
T
-2

The problem is raised by the conflict of libssl. So, the solution is that:

ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
Tryst answered 23/7, 2019 at 19:6 Comment(1)
This didn't work for me. Still looking for a solution. Meanwhile the Google Cloud SDK in unusable on my Mac. I did download/extract the latest SDK, and got the "unsupported hash type" error when I tried to run "./google-cloud-sdk/install.sh".Poinsettia

© 2022 - 2024 — McMap. All rights reserved.