gsutil von gcloud/Google Cloud SDK schlägt mit dem Fehler „SyntaxError: ungültige Syntax“ in bcrypt fehl

gsutil von gcloud/Google Cloud SDK schlägt mit dem Fehler „SyntaxError: ungültige Syntax“ in bcrypt fehl

Beim heutigen Verwendungsversuch gsutilist folgende Fehlermeldung aufgetreten:

+ gsutil cp -nra public-read a gs://b

/usr/local/lib/python2.7/dist-packages/cryptography/__init__.py:39: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in a future release.
  CryptographyDeprecationWarning,
Traceback (most recent call last):
  File "/usr/lib/google-cloud-sdk/bin/bootstrapping/gsutil.py", line 13, in <module>
    import bootstrapping
  File "/usr/lib/google-cloud-sdk/bin/bootstrapping/bootstrapping.py", line 44, in <module>
    from googlecloudsdk.core.credentials import store as c_store
  File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/core/credentials/store.py", line 40, in <module>
    from googlecloudsdk.core.credentials import creds as c_creds
  File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/core/credentials/creds.py", line 34, in <module>
    from googlecloudsdk.core.credentials import devshell as c_devshell
  File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/core/credentials/devshell.py", line 33, in <module>
    from google.oauth2 import credentials
  File "/usr/lib/google-cloud-sdk/lib/third_party/google/oauth2/credentials.py", line 43, in <module>
    from google.oauth2 import _client
  File "/usr/lib/google-cloud-sdk/lib/third_party/google/oauth2/_client.py", line 35, in <module>
    from google.auth import jwt
  File "/usr/lib/google-cloud-sdk/lib/third_party/google/auth/jwt.py", line 57, in <module>
    from google.auth import _service_account_info
  File "/usr/lib/google-cloud-sdk/lib/third_party/google/auth/_service_account_info.py", line 22, in <module>
    from google.auth import crypt
  File "/usr/lib/google-cloud-sdk/lib/third_party/google/auth/crypt/__init__.py", line 43, in <module>
    from google.auth.crypt import rsa
  File "/usr/lib/google-cloud-sdk/lib/third_party/google/auth/crypt/rsa.py", line 20, in <module>
    from google.auth.crypt import _cryptography_rsa
  File "/usr/lib/google-cloud-sdk/lib/third_party/google/auth/crypt/_cryptography_rsa.py", line 25, in <module>
    from cryptography.hazmat.primitives import serialization
  File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/primitives/serialization/__init__.py", line 22, in <module>
    from cryptography.hazmat.primitives.serialization.ssh import (
  File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/primitives/serialization/ssh.py", line 27, in <module>
    from bcrypt import kdf as _bcrypt_kdf
  File "/usr/local/lib/python2.7/dist-packages/bcrypt/__init__.py", line 57
    def gensalt(rounds: int = 12, prefix: bytes = b"2b") -> bytes:
SyntaxError: invalid syntax

Ich verwende gsutil mit Python 2 ( export CLOUDSDK_GSUTIL_PYTHON=python2) und es scheint, als ob das Tool oder das Betriebssystem über Nacht bcrypt 3.2.0 installiert hat, wasUnterstützung für Python 2 eingestellt.

Dadurch wird das Tool gsutil beschädigt.

Antwort1

Die Lösung besteht darin, vor dem Ausführen des Tools manuell auf bcrypt 3.1.7 herunterzustufen:

sudo pip install --system bcrypt==3.1.7

verwandte Informationen