Gsutil: 在 Python 3.9 上遇到错误 - AttributeError: module 'base64' has no attribute 'decodestring'

创建于 2020-10-14  ·  9评论  ·  资料来源: GoogleCloudPlatform/gsutil

微软的应用中心最近更新到 Python 3.9,我在上面运行 gsutil 时遇到如下错误:

Traceback (most recent call last):
  File "/usr/local/bin/gsutil", line 5, in <module>
    from gslib.__main__ import main
  File "/usr/local/lib/python3.9/site-packages/gslib/__main__.py", line 92, in <module>
    from gslib.command_runner import CommandRunner
  File "/usr/local/lib/python3.9/site-packages/gslib/command_runner.py", line 64, in <module>
    from gslib.tests.util import HAS_NON_DEFAULT_GS_HOST
  File "/usr/local/lib/python3.9/site-packages/gslib/tests/util.py", line 126, in <module>
    TEST_ENCRYPTION_KEY1_SHA256_B64 = Base64Sha256FromBase64EncryptionKey(
  File "/usr/local/lib/python3.9/site-packages/gslib/utils/encryption_helper.py", line 152, in Base64Sha256FromBase64EncryptionKey
    decoded_bytes = base64.decodestring(csek_encryption_key)
AttributeError: module 'base64' has no attribute 'decodestring'

此错误由gsutil -o Credentials:gs_service_key_file=./mykey.json cp src_url dist_url命令触发。

关于如何让这个命令在 Python 3.9 上工作的任何想法? 谢谢你。

最有用的评论

export CLOUDSDK_PYTHON=python2.7

所有9条评论

如果有人在应用中心遇到同样的问题,我设法找到了一个临时修复方法
python3.8 -m pip install gsutil
以便它使用 python 3.8 运行 gsutil。

但是,它仍然不能解决在 python 3.9 上运行 gsutil 的问题。

export CLOUDSDK_PYTHON=python2.7

导出 CLOUDSDK_PYTHON=python2.7

我试过了,它gsutil cp将我的 wasm 文件上传为application/octet而不是application/wasm ,这破坏了我的应用程序。 所以要小心,并且更喜欢

export CLOUDSDK_PYTHON=python3.8

如果您的系统上安装了 3.8。

export CLOUDSDK_PYTHON=python2.7

我在我的 Mac 上的~/.zshrc文件中添加了这段代码。
固定的。 感谢那

此问题已在与 Cloud SDK 319.0.0 一起发布的 gsutil v4.55 中得到修复。 如果问题仍然存在,请随时再次打开它。

我刚刚遇到了来自 AUR 的 gsutil v4.57 的类似问题: https ://aur.archlinux.org/packages/google-cloud-sdk

只有这一次,它是module 'base64' has no attribute 'encodestring'

如果重要的话,我有gcloud config set pass_credentials_to_gsutil false并使用gsutil config -a进行身份验证

尝试使用运行 Cloud SDK 342.0.0 的 CLI 在我的存储桶中上传文件时遇到AttributeError: module 'base64' has no attribute 'decodestring'

这也在这里报告了https://github.com/GoogleCloudPlatform/gsutil/issues/1284。 重开这个。

@ayy-em , decodestring 函数调用已经被 b64decode 替换了https://github.com/GoogleCloudPlatform/gsutil/blob/eadfefb0abcddef32d20b44c948c6eb3182aedab/gslib/utils/encryption_helper.py#L152

您能否通过运行gsutil ver -l检查您的 gsutil 版本?

此页面是否有帮助?
0 / 5 - 0 等级