authentication - 为什么 Google Cloud Translate 上的持久 503 服务不可用?

标签 authentication gcloud google-translate google-api-python-client http-status-code-503

每当我向 Gcloud Translate 发出请求时,都会收到 503 错误:“服务此时不可用”。

以下是使用 Python API 的步骤:

>>> import os
>>> from google.cloud import translate_v2 as translate
>>> source_lang_code = 'nl'
>>> target_lang_code = 'en'

>>> os.environ['GOOGLE_APPLICATION_CREDENTIALS']
'/home/Documents/translate/[..keyfilename...].json'

>>> txt = open( ifn, 'r' ).read()
>>> txt[-10:]
'tuurlijk.\n'

>>> translator = translate.Client()
>>> T = translator.translate( txt, source_language=source_lang_code, target_language=target_lang_code )

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/yoozer/anaconda3/lib/python3.7/site-packages/google/cloud/translate_v2/client.py", line 268, in translate
    response = self._connection.api_request(method="POST", path="", data=data)
  File "/home/yoozer/anaconda3/lib/python3.7/site-packages/google/cloud/_http.py", line 393, in api_request
    raise exceptions.from_http_response(response)
google.api_core.exceptions.ServiceUnavailable: 503 POST https://translation.googleapis.com/language/translate/v2: The service is unavailable at this time.

最佳答案

您的代码没有问题。 HTTP 503 表示该服务在处理请求时出现问题。你应该在一段时间后尝试。

如果你看definition 503 中写道:

The server is currently unable to handle the request due to a temporary overload or scheduled maintenance, which will likely be alleviated after some delay.

关于authentication - 为什么 Google Cloud Translate 上的持久 503 服务不可用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58993775/

相关文章:

PHP登录数据库连接错误

java - @AuthenticationPrincipal 抛出异常

使用日志运行的 gcloud 预览应用程序不再有效?

linux - 无法在 Linux 中通过 SSH 连接到 Compute Engine 实例

python - 如何告诉 Googletrans 忽略某些部分?

google-translate - 如何让谷歌翻译的部分语言下拉列表工作?

node.js - 将 auth0 集成到 web 应用程序 express/node js 中

c# - 在网站之间共享 cookie

python - 无法将本地文件夹同步到 gcloud

css - 你能设计谷歌翻译插件吗?