LarryDpk
发布于 2021-05-10 / 2575 阅读
0

Mac安装Google Cloud SDK

前提条件

Cloud SDK 要求安装 Python;支持的版本是 Python 3(首选,3.5 到 3.8)和 Python 2(2.7.9 或更高版本)。查看本机信息:

$ python -V
Python 2.7.16

$ python3 -V
Python 3.7.3

安装

下载包

到以下界面下载:https://cloud.google.com/sdk/docs/install?hl=zh-cn

根据系统下载对应的包:

$ uname -m
x86_64

解压

解压下载的软件包:

$ tar -xvzf google-cloud-sdk-337.0.0-darwin-x86_64.tar.gz

解压后安装

执行解压后的install.sh脚本:

$ ./install.sh

安装成功后会修改bash_profile文件,添加相关的SDK配置:

# The next line updates PATH for the Google Cloud SDK.
if [ -f '/Users/larry/Software/google-cloud-sdk/path.bash.inc' ]; then . '/Users/larry/Software/google-cloud-sdk/path.bash.inc'; fi

# The next line enables shell command completion for gcloud.
if [ -f '/Users/larry/Software/google-cloud-sdk/completion.bash.inc' ]; then . '/Users/larry/Software/google-cloud-sdk/completion.bash.inc'; fi

使环境变量生效:

$ source /Users/larry/.bash_profile

或者打开新终端,也可使更改生效。

测试:

$ gcloud version
Google Cloud SDK 337.0.0
bq 2.0.67
core 2021.04.16
gsutil 4.61

说明成功安装。

通过以下命令可查看所安装的组件:

$ gcloud components list

如果要安装/卸载,通过以下命令:

$ gcloud components install COMPONENT_ID
$ gcloud components remove COMPONENT_ID

参考:官方文档