l'installation de google-cloud-sdk échoue en raison d'une erreur de syntaxe python


12

sur un "Linux supermicro 4.15.0-72-generic # 81-Ubuntu SMP mar 26 nov 12:20:02 UTC 2019 x86_64 x86_64 x86_64 GNU / Linux" Je vois cela se produire lorsque je fais "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

Google n'est pas mon ami, je n'arrive pas à retrouver quelle est la cause de cela. Cela se produit après une "mise à niveau apt", j'ai donc tous les derniers packages (python, ...)

Réponses:


12

Il s'agit d'un problème connu qui a commencé à se produire avec la sortie de la version 274.0.0 Cloud SDK. L'installation a tendance à se poursuivre même si l'erreur est levée (vérifiez la version Cloud SDK avec gcloud info). L'ingénierie en est consciente et elle y réfléchit.

La solution de contournement actuelle consiste à installer une version précédente du SDK Cloud, telle que 272.0.0 avec sudo apt-get install google-cloud-sdk=272.0.0-0.

Mise à jour :

Le problème a été résolu avec la sortie de la version 275.0.0 du SDK Cloud - l'installation du SDK Cloud avec les outils de package basés sur Linux ne devrait plus renvoyer l'erreur susmentionnée. Si vous rencontrez toujours des problèmes, veuillez ouvrir un fil de suivi des problèmes sous le composant Cloud SDK expliquant le problème que vous rencontrez.


mmh .. pas tout à fait: kgoderis @ supermicro: / usr / share $ gcloud info -bash: / home / kgoderis / google-cloud-sdk / bin / gcloud: Aucun fichier ou répertoire de ce type
Karel Goderis

@KarelGoderis Essayez d'installer une version précédente du Cloud SDK avec sudo apt-get install google-cloud-sdk=273.0.0-0et voyez si le problème persiste.
Maxim

La version plus ancienne échoue pour moi avec ce qui suit 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)
Adam Williams

2
@AdamWilliams Cela semble être un problème distinct mais probablement lié, je l'ai également reproduit de mon côté. J'ai fait quelques tests supplémentaires et j'ai finalement réussi à installer la version 272.0.0 du SDK Cloud avec sudo apt-get install google-cloud-sdk=272.0.0-0. Essayez plutôt cela.
Maxim

@Maxim - Merci - L'installation de 272 a fonctionné pour l'installation du serveur Ubuntu 18.04. 274 a échoué comme la note ci-dessus.
user2578083

1

Python3

Je rencontrais la même erreur de syntaxe YAMLObjectMetaclass et j'ai résolu le problème en configurant gcloud, gsutil et bq pour utiliser Python 3 en définissant les variables d'environnement suivantes:

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

voir: démarrage du sujet gcloud

Après avoir défini les 3 variables d'environnement ci-dessus, j'ai réussi à installer gcloud sdk 274.0.1-0.

Bloc de code 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

Générer la sortie:

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

Au moins sur Ubuntu 19.10 (eoan), le SDK continue d'utiliser python2.7 pendant l'installation ("Configuration de google-cloud-sdk (274.0.1-0) ...") malgré la définition de ces variables d'environnement.
Antoine Cotten
En utilisant notre site, vous reconnaissez avoir lu et compris notre politique liée aux cookies et notre politique de confidentialité.
Licensed under cc by-sa 3.0 with attribution required.