gpt4 book ai didi

python - 谷歌云外壳 HttpAccessTokenRefreshError : This can occur if a VM was created with no service account or scopes

转载 作者:行者123 更新时间:2023-11-28 18:22:08 26 4
gpt4 key购买 nike

我正在尝试运行一个简单的脚本 https://github.com/GoogleCloudPlatform/training-data-analyst/blob/master/courses/data_analysis/lab2/python/grepc.py(此代码是连接到 Google 存储的 Dataflow 管道)

上周成功了。但是当我现在运行它时,我总是得到同样的错误:

> Traceback (most recent call last):
File "grepc.py", line 50, in <module>
run()
File "grepc.py", line 44, in run
| 'write' >> beam.io.WriteToText(output_prefix)
File "/usr/local/lib/python2.7/dist-packages/apache_beam/io/textio.py", line 391, in __init__
skip_header_lines=skip_header_lines)
File "/usr/local/lib/python2.7/dist-packages/apache_beam/io/textio.py", line 89, in __init__
validate=validate)
File "/usr/local/lib/python2.7/dist-packages/apache_beam/io/filebasedsource.py", line 105, in __init__
self._validate()
File "/usr/local/lib/python2.7/dist-packages/apache_beam/options/value_provider.py", line 109, in _f
return fnc(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/apache_beam/io/filebasedsource.py", line 165, in _validate
match_result = FileSystems.match([pattern], limits=[1])[0]
File "/usr/local/lib/python2.7/dist-packages/apache_beam/io/filesystems.py", line 131, in match
return filesystem.match(patterns, limits)
File "/usr/local/lib/python2.7/dist-packages/apache_beam/io/gcp/gcsfilesystem.py", line 138, in match
raise BeamIOError("Match operation failed", exceptions)
apache_beam.io.filesystem.BeamIOError: Match operation failed with exceptions {'gs://{MY_BUCKET}/javahelp/*.java': HttpAccessTokenRefreshError(u' This can occur if a VM was created with no service account or scopes.',)}

我不知道如何解决这个问题。大量谷歌搜索也无济于事。

最佳答案

获取新的用户凭据以用于应用程序默认凭据解决了我的问题。

这是我用的

gcloud auth application-default login

此处有详细记录https://cloud.google.com/sdk/gcloud/reference/auth/application-default/login

您可以在此处找到解释:如果您正在开发通常使用服务帐户但需要在更容易提供用户凭据的本地开发环境中运行代码的代码,此命令很有用。凭据将应用于所有使用应用程序默认凭据客户端库的 API 调用

我找到的另一个解决方案是:下载计算引擎服务帐户的 key 文件并导出 GOOGLE_APPLICATION_CREDENTIALS 以指向 key 文件

关于python - 谷歌云外壳 HttpAccessTokenRefreshError : This can occur if a VM was created with no service account or scopes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44430393/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com