google-cloud-sdk安装由于python语法错误而失败


12

在“ Linux supermicro 4.15.0-72-generic#81-Ubuntu SMP Tue Nov 26 12:20:02 UTC 2019 x86_64 x86_64 x86_64 GNU / Linux”上,我在执行“ sudo apt-get install google-cloud- sdk”

> Reading package lists... Done Building dependency tree        Reading
> state information... Done Suggested packages:  
> google-cloud-sdk-app-engine-java google-cloud-sdk-app-engine-python
> google-cloud-sdk-pubsub-emulator google-cloud-sdk-bigtable-emulator
> google-cloud-sdk-datastore-emulator kubectl The following NEW packages
> will be installed:   google-cloud-sdk 0 upgraded, 1 newly installed, 0
> to remove and 13 not upgraded. Need to get 0 B/25.0 MB of archives.
> After this operation, 194 MB of additional disk space will be used.
> Selecting previously unselected package google-cloud-sdk. (Reading
> database ... 267451 files and directories currently installed.)
> Preparing to unpack .../google-cloud-sdk_274.0.0-0_all.deb ...
> Unpacking google-cloud-sdk (274.0.0-0) ... Setting up google-cloud-sdk
> (274.0.0-0) ... Compiling
> platform/bq/third_party/yaml/lib3/__init__.py ...   File
> "platform/bq/third_party/yaml/lib3/__init__.py", line 284
>     class YAMLObject(metaclass=YAMLObjectMetaclass):
>                               ^ SyntaxError: invalid syntax

谷歌不是我的朋友,我找不到原因。这是在“ apt升级”之后发生的,所以我拥有所有最新的软件包(python,...)

Answers:


12

这是一个已知问题,从274.0.0 Cloud SDK版本的发布开始。即使抛出错误,安装过程也很容易完成(请使用来检查Cloud SDK版本gcloud info)。工程知道,他们正在研究它。

当前的解决方法是使用来安装Cloud SDK的早期版本,例如272.0.0 sudo apt-get install google-cloud-sdk=272.0.0-0

更新

Cloud SDK版本275.0.0已解决了该问题-使用基于Linux的打包工具安装Cloud SDK不会再引发上述错误。如果您仍然遇到问题,请在Cloud SDK组件下打开一个Issue Tracker线程,以解释您遇到的问题。


mmh ..不太完全:kgoderis @ supermicro:/ usr / share $ gcloud信息-bash:/ home / kgoderis / google-cloud-sdk / bin / gcloud:没有这样的文件或目录
Karel Goderis

@KarelGoderis尝试使用来安装Cloud SDK的早期版本,sudo apt-get install google-cloud-sdk=273.0.0-0并查看问题是否仍然存在。
Maxim

较旧的版本对我而言失败了 Compiling lib/googlecloudsdk/api_lib/dns/active_peering_zones.py ... SyntaxError: future feature google_type_annotations is not defined (active_peering_zones.py, line 19)
亚当·威廉姆斯

2
@AdamWilliams这似乎是一个单独的问题,但可能与之相关,我也将其复制了下来。再做一些测试,最终我设法用来安装Cloud SDK版本272.0.0 sudo apt-get install google-cloud-sdk=272.0.0-0。试试吧。
Maxim

@Maxim-谢谢-安装272适用于Ubuntu 18.04 Server安装。274失败,如上述注释。
user2578083 '19

1

Python3

我遇到了相同的YAMLObjectMetaclass语法错误,并通过设置以下环境变量将gcloud,gsutil和bq配置为使用Python 3,从而解决了该问题:

ENV CLOUDSDK_PYTHON=python3
ENV CLOUDSDK_GSUTIL_PYTHON=python3
ENV CLOUDSDK_BQ_PYTHON=python3

请参阅:gcloud主题启动

在上面设置了3个环境变量之后,我能够成功安装gcloud sdk 27​​4.0.1-0。

Dockerfile代码块:

FROM ubuntu:1810
#...removed section for brevity
# install google cloud platform sdk with python3
# see: https://cloud.google.com/sdk/gcloud/reference/topic/startup
ENV CLOUDSDK_PYTHON=python3
# gsutil now supports Python 3.5 and up in addition to Python 2.7.x.
# To use a different interpreter for gsutil than for the other Python tools,
# you can set the desired interpreter by setting
# the CLOUDSDK_GSUTIL_PYTHON environment variable.
ENV CLOUDSDK_GSUTIL_PYTHON=python3
# bq now supports Python 3.5 and up in addition to Python 2.7.x.
# To use a different interpreter for bq than for the other Python tools,
# you can set the desired interpreter by setting the
# CLOUDSDK_BQ_PYTHON environment variable.
ENV CLOUDSDK_BQ_PYTHON=python3
RUN export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" && \
    echo "deb http://packages.cloud.google.com/apt ${CLOUD_SDK_REPO} main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && \
    curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && \
    apt-get update -y && DEBIAN_FRONTEND=noninteractive apt-get install -y \
    google-cloud-sdk \
    kubectl \
    google-cloud-sdk-app-engine-grpc \
    google-cloud-sdk-app-engine-go \
    google-cloud-sdk-cloud-build-local \
    google-cloud-sdk-app-engine-python \
    google-cloud-sdk-cbt \
    google-cloud-sdk-app-engine-python-extras \
    google-cloud-sdk-app-engine-java

构建输出:

2972  ---> 6fa2385d7961
2973 Step 31/59 : ENV CLOUDSDK_PYTHON=python3
2974  ---> Running in 57ff376529c3
2975 Removing intermediate container 57ff376529c3
2976  ---> d99387b3fed7
2977 Step 32/59 : ENV CLOUDSDK_GSUTIL_PYTHON=python3
2978  ---> Running in 5e8170bbdfdd
2979 Removing intermediate container 5e8170bbdfdd
2980  ---> 358dde5de9c4
2981 Step 33/59 : ENV CLOUDSDK_BQ_PYTHON=python3
2982  ---> Running in 0f69d9a9b714
2983 Removing intermediate container 0f69d9a9b714
2984  ---> 76a0a37d12ec
2985 Step 34/59 : RUN export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" &&     echo "deb http://packages.cloud.google.com/apt ${CLOUD_SDK_REPO} main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list &&     curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - &&     apt-get update -y && DEBIAN_FRONTEND=noninteractive apt-get install -y     google-cloud-sdk     kubectl     google-cloud-sdk-app-engine-grpc     google-cloud-sdk-app-engine-go     google-cloud-sdk-cloud-build-local     google-cloud-sdk-app-engine-python     google-cloud-sdk-cbt     google-cloud-sdk-app-engine-python-extras     google-cloud-sdk-app-engine-java
2986  ---> Running in 746a47f450dc
2987 deb http://packages.cloud.google.com/apt cloud-sdk-cosmic main
2988   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
2989                                  Dload  Upload   Total   Spent    Left  Speed
2990 100   659  100   659    0     0   2768      0 --:--:-- --:--:-- --:--:--  2941
2991 Warning: apt-key output should not be parsed (stdout is not a terminal)
2992 OK
2993 Get:1 http://packages.cloud.google.com/apt cloud-sdk-cosmic InRelease [6,372 B]
2994 Hit:2 https://download.docker.com/linux/ubuntu cosmic InRelease
2995 Hit:3 http://security.ubuntu.com/ubuntu cosmic-security InRelease
2996 Hit:4 http://archive.ubuntu.com/ubuntu cosmic InRelease
2997 Hit:5 http://archive.ubuntu.com/ubuntu cosmic-updates InRelease
2998 Ign:6 http://packages.cloud.google.com/apt cloud-sdk-cosmic/main amd64 Packages
2999 Hit:7 http://archive.ubuntu.com/ubuntu cosmic-backports InRelease
3000 Get:6 http://packages.cloud.google.com/apt cloud-sdk-cosmic/main amd64 Packages [40.9 kB]
3001 Fetched 47.3 kB in 1s (53.7 kB/s)
3002 Reading package lists...
3003 Reading package lists...
3004 Building dependency tree...
3005 Reading state information...
3006 The following additional packages will be installed:
3007   python-crcmod
3008 Suggested packages:
3009   google-cloud-sdk-pubsub-emulator google-cloud-sdk-bigtable-emulator
3010   google-cloud-sdk-datastore-emulator
3011 The following NEW packages will be installed:
3012   google-cloud-sdk google-cloud-sdk-app-engine-go
3013   google-cloud-sdk-app-engine-grpc google-cloud-sdk-app-engine-java
3014   google-cloud-sdk-app-engine-python google-cloud-sdk-app-engine-python-extras
3015   google-cloud-sdk-cbt google-cloud-sdk-cloud-build-local kubectl
3016   python-crcmod
3017 0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded.
3018 Need to get 119 MB of archives.
3019 After this operation, 548 MB of additional disk space will be used.
3020 Get:1 http://packages.cloud.google.com/apt cloud-sdk-cosmic/main amd64 google-cloud-sdk all 274.0.1-0 [25.0 MB]
3021 Get:2 http://archive.ubuntu.com/ubuntu cosmic/universe amd64 python-crcmod amd64 1.7+dfsg-1build1 [17.8 kB]
3022 Get:3 http://packages.cloud.google.com/apt cloud-sdk-cosmic/main amd64 google-cloud-sdk-app-engine-python all 274.0.1-0 [4,278 kB]
3023 Get:4 http://packages.cloud.google.com/apt cloud-sdk-cosmic/main amd64 google-cloud-sdk-app-engine-go amd64 274.0.1-0 [2,296 kB]
3024 Get:5 http://packages.cloud.google.com/apt cloud-sdk-cosmic/main amd64 google-cloud-sdk-app-engine-grpc amd64 274.0.1-0 [1,558 kB]
3025 Get:6 http://packages.cloud.google.com/apt cloud-sdk-cosmic/main amd64 google-cloud-sdk-app-engine-java all 274.0.1-0 [56.5 MB]
3026 Get:7 http://packages.cloud.google.com/apt cloud-sdk-cosmic/main amd64 google-cloud-sdk-app-engine-python-extras all 274.0.1-0 [14.9 MB]
3027 Get:8 http://packages.cloud.google.com/apt cloud-sdk-cosmic/main amd64 google-cloud-sdk-cbt amd64 274.0.1-0 [3,387 kB]
3028 Get:9 http://packages.cloud.google.com/apt cloud-sdk-cosmic/main amd64 google-cloud-sdk-cloud-build-local amd64 274.0.1-0 [2,771 kB]
3029 Get:10 http://packages.cloud.google.com/apt cloud-sdk-cosmic/main amd64 kubectl amd64 1.17.0-00 [8,742 kB]
3030 debconf: delaying package configuration, since apt-utils is not installed
3031 Fetched 119 MB in 10s (11.7 MB/s)
3032 Selecting previously unselected package python-crcmod.
3033 (Reading database ... 41146 files and directories currently installed.)
3034 Preparing to unpack .../0-python-crcmod_1.7+dfsg-1build1_amd64.deb ...
3035 Unpacking python-crcmod (1.7+dfsg-1build1) ...
3036 Selecting previously unselected package google-cloud-sdk.
3037 Preparing to unpack .../1-google-cloud-sdk_274.0.1-0_all.deb ...
3038 Unpacking google-cloud-sdk (274.0.1-0) ...
3039 Selecting previously unselected package google-cloud-sdk-app-engine-python.
3040 Preparing to unpack .../2-google-cloud-sdk-app-engine-python_274.0.1-0_all.deb ...
3041 Unpacking google-cloud-sdk-app-engine-python (274.0.1-0) ...
3042 Selecting previously unselected package google-cloud-sdk-app-engine-go.
3043 Preparing to unpack .../3-google-cloud-sdk-app-engine-go_274.0.1-0_amd64.deb ...
3044 Unpacking google-cloud-sdk-app-engine-go (274.0.1-0) ...
3045 Selecting previously unselected package google-cloud-sdk-app-engine-grpc.
3046 Preparing to unpack .../4-google-cloud-sdk-app-engine-grpc_274.0.1-0_amd64.deb ...
3047 Unpacking google-cloud-sdk-app-engine-grpc (274.0.1-0) ...
3048 Selecting previously unselected package google-cloud-sdk-app-engine-java.
3049 Preparing to unpack .../5-google-cloud-sdk-app-engine-java_274.0.1-0_all.deb ...
3050 Unpacking google-cloud-sdk-app-engine-java (274.0.1-0) ...
3051 Selecting previously unselected package google-cloud-sdk-app-engine-python-extras.
3052 Preparing to unpack .../6-google-cloud-sdk-app-engine-python-extras_274.0.1-0_all.deb ...
3053 Unpacking google-cloud-sdk-app-engine-python-extras (274.0.1-0) ...
3054 Selecting previously unselected package google-cloud-sdk-cbt.
3055 Preparing to unpack .../7-google-cloud-sdk-cbt_274.0.1-0_amd64.deb ...
3056 Unpacking google-cloud-sdk-cbt (274.0.1-0) ...
3057 Selecting previously unselected package google-cloud-sdk-cloud-build-local.
3058 Preparing to unpack .../8-google-cloud-sdk-cloud-build-local_274.0.1-0_amd64.deb ...
3059 Unpacking google-cloud-sdk-cloud-build-local (274.0.1-0) ...
3060 Selecting previously unselected package kubectl.
3061 Preparing to unpack .../9-kubectl_1.17.0-00_amd64.deb ...
3062 Unpacking kubectl (1.17.0-00) ...
3063 Setting up python-crcmod (1.7+dfsg-1build1) ...
3064 Setting up kubectl (1.17.0-00) ...
3065 Setting up google-cloud-sdk (274.0.1-0) ...
3066 Setting up google-cloud-sdk-app-engine-python (274.0.1-0) ...
3067 Setting up google-cloud-sdk-app-engine-grpc (274.0.1-0) ...
3068 Setting up google-cloud-sdk-cloud-build-local (274.0.1-0) ...
3069 Setting up google-cloud-sdk-cbt (274.0.1-0) ...
3070 Processing triggers for google-cloud-sdk (274.0.1-0) ...
3071 Setting up google-cloud-sdk-app-engine-java (274.0.1-0) ...
3072 Setting up google-cloud-sdk-app-engine-go (274.0.1-0) ...
3073 Setting up google-cloud-sdk-app-engine-python-extras (274.0.1-0) ...
3074 Processing triggers for google-cloud-sdk (274.0.1-0) ...
3075 Removing intermediate container 746a47f450dc
3076  ---> c128e79ea8f1
3077 Step 35/59 : RUN apt-get update --fix-missing && DEBIAN_FRONTEND=noninteractive apt-get upgrade -y && apt-get dist-upgrade -y
3078  ---> Running in 0b74e8d18d1b
3079 Hit:1 http://packages.cloud.google.com/apt cloud-sdk-cosmic InRelease
3080 Hit:2 http://archive.ubuntu.com/ubuntu cosmic InRelease
3081 Hit:3 https://download.docker.com/linux/ubuntu cosmic InRelease
3082 Hit:4 http://security.ubuntu.com/ubuntu cosmic-security InRelease
3083 Hit:5 http://archive.ubuntu.com/ubuntu cosmic-updates InRelease
3084 Hit:6 http://archive.ubuntu.com/ubuntu cosmic-backports InRelease
3085 Reading package lists...
3086 Reading package lists...
3087 Building dependency tree...
3088 Reading state information...
3089 Calculating upgrade...
3090 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
3091 Reading package lists...
3092 Building dependency tree...
3093 Reading state information...
3094 Calculating upgrade...
3095 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
3096 Removing intermediate container 0b74e8d18d1b
3097  ---> 85cca2b48996
3098 Step 36/59 : WORKDIR ${DOCKER_IMAGE_USER_HOME}
3099  ---> Running in 63c9f8ce5e1d

至少在Ubuntu 19.10(eoan)上,SDK会在安装过程中继续使用python2.7 (“设置google-cloud-sdk(274.0.1-0)...”),尽管设置了这些环境变量。
Antoine Cotten
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.