gcloud/Google Cloud SDK の gsutil が bcrypt で「SyntaxError: 無効な構文」エラーで失敗する

gcloud/Google Cloud SDK の gsutil が bcrypt で「SyntaxError: 無効な構文」エラーで失敗する

今日使用しようとするとgsutil、次のエラーが発生しました:

+ 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

私はPython 2(export CLOUDSDK_GSUTIL_PYTHON=python2)でgsutilを実行していますが、ツールまたはOSが一晩でbcrypt 3.2.0をインストールしたようです。Python 2のサポートを終了しました

これにより、gsutil ツールが壊れます。

答え1

修正するには、ツールを実行する前に手動で bcrypt 3.1.7 にダウングレードします。

sudo pip install --system bcrypt==3.1.7

関連情報