2

I'm trying to install gcloud on Mac using the following guide: Quickstart for macOS I got the following error while executing the install.sh script

Pratyushs-MacBook-Pro-2:~ pratyush$ ./google-cloud-sdk\ 2/install.sh 
Welcome to the Google Cloud SDK!
Traceback (most recent call last):
  File "/Users/pratyush/./google-cloud-sdk 2/bin/bootstrapping/install.py", line 12, in <module>
    import bootstrapping
  File "/Users/pratyush/google-cloud-sdk 2/bin/bootstrapping/bootstrapping.py", line 44, in <module>
    from googlecloudsdk.core.credentials import store as c_store
  File "/Users/pratyush/google-cloud-sdk 2/lib/googlecloudsdk/core/credentials/store.py", line 36, in <module>
    from googlecloudsdk.core.credentials import creds
  File "/Users/pratyush/google-cloud-sdk 2/lib/googlecloudsdk/core/credentials/creds.py", line 37, in <module>
    import sqlite3
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sqlite3/__init__.py", line 24, in <module>
    from dbapi2 import *
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sqlite3/dbapi2.py", line 28, in <module>
    from _sqlite3 import *
ImportError: dlopen(/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_sqlite3.so, 2): Symbol not found: _sqlite3_enable_load_extension
  Referenced from: /usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_sqlite3.so
  Expected in: /usr/lib/libsqlite3.dylib
 in /usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_sqlite3.so
Pratyushs-MacBook-Pro-2:~ pratyush$ 

Python Version: 2.7.15 Mac: High Sierra v10.13.4

Could someone please help me resolve this error?

Thank you.

1 Answer 1

3

The install script is failing because it's running the system Python 2 interpreter (at /usr/bin/python). As you have discovered, the default Python interpreter that ships with macOS is a source of much grief. It should never be used. Apple is removing it from future macOS releases.

1. Install a proper version of Python

To install gcloud, you first need to install an up-to-date Python 3 interpreter with brew.

$ brew install python

2. Verify the Good Pythontm is being used

The new interpreter will be installed at /usr/local/bin/python3. Verify that it's being prioritized over the system Python with which -a.

$ which -a python3
/usr/local/bin/python3
/usr/bin/python3

If /usr/local/bin/python3 is not the first result, edit your $PATH and make sure /usr/local/bin appears before /usr/bin.

$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

3. Install gcloud

$ brew install --cask google-cloud-sdk

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .