reference: https://cloud.google.com/cli?hl=en

NOTE

This is instructions for MacOS

For other OS use links below

LinuxDebian/UbuntuRed Hat/Fedora/CentOSmacOSWindows

  1. Confirm that you have a supported version of Python:
    • To check your current Python version, run python3 -V or python -V. Supported versions are Python 3.8 to 3.12.
    • The main install script offers to install CPython’s Python 3.11.
    • Otherwise, to install a supported Python version, please visit the Python.orgPython Releases for macOS.
    • If you have multiple Python interpreters installed on your machine, set the CLOUDSDK_PYTHON environment variable within your shell to point to the path of your preferred interpreter.
    • For more information on how to choose and configure your Python interpreter, seegcloud topic startup.
  2. Download one of the following:

NOTE

 To determine your machine hardware name, run `uname -m` from a command line.
PlatformPackageSize
macOS 64-bit

(x86_64)
google-cloud-cli-darwin-x86_64.tar.gz53.7 MB
macOS 64-bit

(ARM64, Apple M1 silicon)
google-cloud-cli-darwin-arm.tar.gz53.7 MB
macOS 32-bit

(x86)
google-cloud-cli-darwin-x86.tar.gz52.4 MB

a. Extract the archive to any location on your file system (preferably your Home directory). On macOS, this can be achieved by opening the downloaded .tar.gzarchive file in the preferred location.

b. (Optional) Use the install script to add gcloud CLI tools to your PATH.You can also opt-in to command-completion for your shell, usage statistics collection, and install Python 3.11.

./google-cloud-sdk/install.sh

3. To initialize the gcloud CLI, run gcloud init:

Optional. Install additional components using the component manager.