今天尝试使用时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,似乎该工具或操作系统在一夜之间安装了 bcrypt 3.2.0,不再支持 Python 2。
这会破坏 gsutil 工具。
答案1
修复方法是在运行该工具之前手动降级到 bcrypt 3.1.7:
sudo pip install --system bcrypt==3.1.7