通过 pip 安装的 Google Cloud SDK:“gsutil 需要 python 2.7”

Posted

技术标签:

【中文标题】通过 pip 安装的 Google Cloud SDK:“gsutil 需要 python 2.7”【英文标题】:Google Cloud SDK installed via pip: "gsutil requires python 2.7" 【发布时间】:2018-12-30 09:56:50 【问题描述】:

我正在尝试在我的 Macbook Pro 上安装 Google Cloud SDK。如果我尝试按照https://cloud.google.com/storage/docs/gsutil_install 下载并运行 bash 脚本,

curl https://sdk.cloud.google.com | bash

我收到以下错误:

For the latest full release notes, please visit:
  https://cloud.google.com/sdk/release_notes

╔════════════════════════════════════════════════════════════╗
╠═ Creating update staging area                             ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: BigQuery Command Line Tool                   ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: BigQuery Command Line Tool (Platform Spec... ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Cloud SDK Core Libraries (Platform Specific) ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Cloud Storage Command Line Tool              ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Cloud Storage Command Line Tool (Platform... ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: Default set of gcloud commands               ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: gcloud cli dependencies                      ═╣
ERROR: (gcloud.components.update) The component [gcloud-deps-darwin-x86_64] failed to download.

或者,如果我尝试使用sudo pip install gsutil 安装它,然后尝试运行它,我会收到以下错误:

Kurts-MacBook-Pro:peek-solutions2 kurtpeek$ gsutil --help
gsutil requires python 2.7.

使用pyenv 将 Python 版本设置为 2.7 后,我仍然收到此错误:

Kurts-MacBook-Pro:peek-solutions2 kurtpeek$ pyenv versions
  system
* 2.7 (set by PYENV_VERSION environment variable)
  3.6.5

如何安装gsutil 的工作版本?

【问题讨论】:

【参考方案1】:

在https://cloud.google.com/sdk/docs/quickstart-macos 之后,我下载了.tar.gz 文件并运行./google-cloud-sdk/install.sh,现在它可以工作了:

Kurts-MacBook-Pro:~ kurtpeek$ gsutil --help
Usage: gsutil [-D] [-DD] [-h header]... [-m] [-o] [-q] [command [opts...] args...]
Available commands:
  acl             Get, set, or change bucket and/or object ACLs
  cat             Concatenate object content to stdout
  compose         Concatenate a sequence of objects into a new composite object.
  config          Obtain credentials and create configuration file
  cors            Get or set a CORS JSON document for one or more buckets
  cp              Copy files and objects
  defacl          Get, set, or change default ACL on buckets
  defstorageclass Get or set the default storage class on buckets
  du              Display object size usage
  hash            Calculate file hashes
  help            Get help about commands and topics
  iam             Get, set, or change bucket and/or object IAM permissions.
  kms             Configure Cloud KMS encryption
  label           Get, set, or change the label configuration of a bucket.
  lifecycle       Get or set lifecycle configuration for a bucket
  logging         Configure or retrieve logging on buckets
  ls              List providers, buckets, or objects
  mb              Make buckets
  mv              Move/rename objects and/or subdirectories
  notification    Configure object change notification
  perfdiag        Run performance diagnostic
  rb              Remove buckets
  requesterpays   Enable or disable requester pays for one or more buckets
  rewrite         Rewrite objects
  rm              Remove objects
  rsync           Synchronize content of two buckets/directories
  setmeta         Set metadata on already uploaded objects
  signurl         Create a signed url
  stat            Display object status
  test            Run gsutil unit/integration tests (for developers)
  update          Update to the latest gsutil release
  version         Print version info about gsutil
  versioning      Enable or suspend versioning for one or more buckets
  web             Set a main page and/or error page for one or more buckets

Additional help topics:
  acls            Working With Access Control Lists
  anon            Accessing Public Data Without Credentials
  apis            Cloud Storage APIs
  crc32c          CRC32C and Installing crcmod
  creds           Credential Types Supporting Various Use Cases
  dev             Contributing Code to gsutil
  encoding        Filename encoding and interoperability problems
  encryption      Using Encryption Keys
  metadata        Working With Object Metadata
  naming          Object and Bucket Naming
  options         Top-Level Command-Line Options
  prod            Scripting Production Transfers
  projects        Working With Projects
  retries         Retry Handling Strategy
  security        Security and Privacy Considerations
  subdirs         How Subdirectories Work
  support         Google Cloud Storage Support
  throttling      Throttling gsutil
  versions        Object Versioning and Concurrency Control
  wildcards       Wildcard Names

Use gsutil help <command or topic> for detailed help.

【讨论】:

这种安装方法总是需要交互,不是吗?我正在尝试在无法响应提示的环境中进行安装。

以上是关于通过 pip 安装的 Google Cloud SDK:“gsutil 需要 python 2.7”的主要内容,如果未能解决你的问题,请参考以下文章

pip install google-cloud-pubsub 在 docker 容器中安装失败

GCE 上没有名为“google.cloud._helpers”的模块

通过 API 从 Google Cloud 访问 YouTube 帐户以获取统计信息

Google Cloud Messaging现在是否在Google中被阻止?

解决在Google Cloud中安装Anaconda时遇到的系列问题

google cloud sdk 怎么安装