38

我正在按照Mac OS X 的快速入门安装云 SDK。完全按照步骤,

1)python -V返回“Python 2.7.10”

./install.sh2)在google-cloud-sdk中使用64位版本的SDK下载解压返回...

Welcome to the Google Cloud SDK!

To help improve the quality of this product, we collect anonymized usage data
and anonymized stacktraces when crashes are encountered; additional information
is available at <https://cloud.google.com/sdk/usage-statistics>. You may choose
to opt out of this collection now (by choosing 'N' at the below prompt), or at
any time in the future by running the following command:

    gcloud config set disable_usage_reporting true

Do you want to help improve the Google Cloud SDK (Y/n)?  Y


Your current Cloud SDK version is: 170.0.1
The latest available version is: 170.0.1

┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                  Components                                                 │
├───────────────┬──────────────────────────────────────────────────────┬──────────────────────────┬───────────┤
│     Status    │                         Name                         │            ID            │    Size   │
├───────────────┼──────────────────────────────────────────────────────┼──────────────────────────┼───────────┤
│ Not Installed │ App Engine Go Extensions                             │ app-engine-go            │  97.7 MiB │
│ Not Installed │ Cloud Bigtable Command Line Tool                     │ cbt                      │   4.0 MiB │
│ Not Installed │ Cloud Bigtable Emulator                              │ bigtable                 │   3.5 MiB │
│ Not Installed │ Cloud Datalab Command Line Tool                      │ datalab                  │   < 1 MiB │
│ Not Installed │ Cloud Datastore Emulator                             │ cloud-datastore-emulator │  15.4 MiB │
│ Not Installed │ Cloud Datastore Emulator (Legacy)                    │ gcd-emulator             │  38.1 MiB │
│ Not Installed │ Cloud Pub/Sub Emulator                               │ pubsub-emulator          │  33.2 MiB │
│ Not Installed │ Emulator Reverse Proxy                               │ emulator-reverse-proxy   │  14.5 MiB │
│ Not Installed │ Google Container Local Builder                       │ container-builder-local  │   3.7 MiB │
│ Not Installed │ Google Container Registry's Docker credential helper │ docker-credential-gcr    │   2.2 MiB │
│ Not Installed │ gcloud Alpha Commands                                │ alpha                    │   < 1 MiB │
│ Not Installed │ gcloud Beta Commands                                 │ beta                     │   < 1 MiB │
│ Not Installed │ gcloud app Java Extensions                           │ app-engine-java          │ 128.1 MiB │
│ Not Installed │ gcloud app PHP Extensions (Mac OS X)                 │ app-engine-php-darwin    │  21.9 MiB │
│ Not Installed │ gcloud app Python Extensions                         │ app-engine-python        │   6.5 MiB │
│ Not Installed │ kubectl                                              │ kubectl                  │  15.9 MiB │
│ Installed     │ BigQuery Command Line Tool                           │ bq                       │   < 1 MiB │
│ Installed     │ Cloud SDK Core Libraries                             │ core                     │   6.7 MiB │
│ Installed     │ Cloud Storage Command Line Tool                      │ gsutil                   │   3.0 MiB │
└───────────────┴──────────────────────────────────────────────────────┴──────────────────────────┴───────────┘
To install or remove components at your current SDK version [170.0.1], run:
  $ gcloud components install COMPONENT_ID
  $ gcloud components remove COMPONENT_ID

To update your SDK installation to the latest version [170.0.1], run:
  $ gcloud components update

==> Source [/Users/shaneoseasnain/Desktop/google-cloud-sdk/completion.bash.inc] in your profile to enable shell command completion for gcloud.
==> Source [/Users/shaneoseasnain/Desktop/google-cloud-sdk/path.bash.inc] in your profile to add the Google Cloud SDK command line tools to your $PATH.

For more information on how to get started, please visit:
  https://cloud.google.com/sdk/docs/quickstarts

3) 我重新启动了终端并gcloud init从 google-cloud-sdk 内部运行。这将返回“ command not found。” 如果我运行ls,我会看到以下目录结构:

LICENSE               completion.zsh.inc      path.fish.inc
README                deb                     path.zsh.inc
RELEASE_NOTES         install.bat             platform
VERSION               install.sh              properties
bin                   lib                     rpm
completion.bash.inc   path.bash.inc

4)我也试过在gcloud init里面跑bin,但遇到同样的问题,command not found.

我可以从安装指南中看到的唯一其他建议是“在 bash shell 中启用命令完成,和/或启用使用情况报告”。我不确定如何执行此操作,但命令完成和报告看起来不应该与此问题相关。有很多相关的文章,command not found但它们与其他问题有关,例如 gcloud 在一段时间后停止工作或旧版本中的问题。有没有人提示如何让云 sdk 工作?

谢谢

4

11 回答 11

89

我遇到过同样的问题。一个懒惰且快速的解决方法是运行:

brew install --cask google-cloud-sdk

通过谷歌搜索找到。

于 2017-11-21T10:26:18.713 回答
28

对于 MAC 操作系统 - 使用 Homebrew

brew install --cask google-cloud-sdk

然后使用

 source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc"
 source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc"
于 2021-03-24T23:51:51.117 回答
10

gcloud可执行文件位于–google-cloud-sdk/bin运行 gcloud。您需要:

  1. 将此目录添加到您的$PATH。特别是,将行添加source /Users/shaneoseasnain/Desktop/google-cloud-sdk/path.bash.inc到您的.bash_profile文件(有关此文件的功能以及如何选择一个的更多详细信息)将起到作用。
  2. 运行时指定gcloud可执行文件的完整路径。在你的情况下,这是/Users/shaneoseasnain/Desktop/google-cloud-sdk/bin/gcloud. 例如:

    $ /Users/shaneoseasnain/Desktop/google-cloud-sdk/bin/gcloud init
    

快速入门的相关部分(已添加重点):

运行安装脚本以将 Cloud SDK 工具添加到您的路径,在您的 bash shell 中启用命令完成,和/或启用使用情况报告:

至于为什么安装脚本不起作用,我不能说。请提出问题,我们将进行调查。

于 2017-09-10T22:11:26.213 回答
8

这是在 MacOS 上。我有同样的问题。我有gcloud: command not found

之后brew install --cask google-cloud-sdk,我发现我必须手动安装它。

  • 首先,您将install.sh在 directory 下找到,您将在终端下google-cloud-sdk运行。.../google-cloud-sdk/install.sh就我而言,该文件位于/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk

  • 二、运行/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/install.sh

  • 第三,由于您的bash文件或zsh文件更新,将有一条消息指导您重新启动终端。

  • 第四,gcloud -v启动新终端后测试 gcloud-cli 是否正常工作。

于 2021-02-08T05:15:19.147 回答
5

简而言之:

emacs -nw ~/.zshrc

并在开头添加以下行:

# The next line updates PATH for the Google Cloud SDK.
source '/home/lesaint/GOOGLE_CLOUD/google-cloud-sdk/path.zsh.inc'

# The next lines enables bash completion in Zsh for gcloud. 
autoload -U compinit compdef
compinit
source '/home/lesaint/GOOGLE_CLOUD/google-cloud-sdk/completion.zsh.inc'

以下文章提出的解决方案对我有用:

http://www.javatronic.fr/tips/2014/10/17/installing_google_cloud_sdk_on_ubuntu_with_oh-my-zsh.html

于 2020-03-13T11:59:34.127 回答
3

以下对我有用:

  • 我将安装程序解压缩包移动到 ~ 目录。
  • 然后在运行 ./google-cloud-sdk/install.sh 之后
  • 我再次重新启动终端并运行'gcloud init'并且它工作。
于 2017-10-12T01:28:41.887 回答
3

TL;DR - 按照安装 Cloud SDK的交互式安装程序部分,SDK 将正确安装。

但是,这里有一个真正的问题,我认为这与缺少环境变量有关:

起初,我也遵循了 Mac OS X 的快速入门,以便为“Mac OS X (x86_64) 平台”安装 Google Cloud SDK。这再现了与Shane在上面的问题中概述的完全相同的结果。以下是更多细节:

  • 在 2017 MacBook Pro 上全新安装 macOS Sierra 10.12.6(最新)。
  • 谷歌云 SDK 版本 173.0.0。具体来说: google-cloud-sdk-173.0.0-darwin-x86_64.tar.gz 这是撰写本文时最新的版本,也是快速入门指南中指出的版本。

我能够在 Mac OS X 快速入门的“开始之前”部分的第 4 步中进一步查明问题:

设置 Cloud SDK 以供使用。如果您无法让 gcloud 命令正常工作,请确保您的 $PATH 定义正确。运行安装脚本以将 Cloud SDK 工具添加到您的路径,在您的 bash shell 中启用命令完成,和/或启用使用情况报告:

./google-cloud-sdk/install.sh

“install.sh”调用“install.py”,它有时会调用isatty()以查明安装过程是否从 shell 运行,这意味着它应该是交互式的并提示用户输入一些信息。出于某种原因,isatty()返回False而不是True!这会导致脚本以非交互方式失败,并且 - 因为 'install.sh' 是在没有参数的情况下调用的 - Fail

于 2017-09-30T09:10:35.893 回答
1

有时,安装后,您只需要重新启动终端即可。而已 :)

看看这里:macOS 的快速入门

于 2019-06-01T00:42:49.670 回答
0

对我来说,这就是解决方法:

mkdir -p $sdk_dir/.install/

tl;博士;

似乎python库正在通过搜索目录来定位sdk_root.install。查看config.pyCLOUDSDK_STATE_DIR的定义

于 2019-09-01T07:43:48.590 回答
0

您的 google-cloud-sdk/bin 似乎没有出现在 PATH 中。

从以下位置复制您当前的 PATH:

echo $PATH

现在将您的 google-cloud-sdk/bin 绝对路径添加到 PATH,不要忘记添加冒号 - ':',在添加新路径之前,它应该是这样的:

PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/Users/user/google-cloud-sdk/bin
于 2022-03-02T12:49:44.813 回答
-2

按着这些次序:

  1. Command+Space并键入终端,然后按enter/return键。

  2. 在终端应用程序中运行:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null ; brew install caskroom/cask/brew-cask 2> /dev/null

如果屏幕提示您输入密码,请输入您的 Mac 用户密码以继续。当您输入密码时,它不会显示在屏幕上,但系统会接受。因此,只需输入您的密码并按ENTER/RETURN键。然后等待命令完成。

brew cask install google-cloud-sdk

参考:

http://macappstore.org/google-cloud-sdk/

于 2018-09-17T15:28:53.273 回答