Authentication 为什么谷歌云翻译上的持久503服务不可用?

Authentication 为什么谷歌云翻译上的持久503服务不可用?,authentication,gcloud,google-translate,google-api-python-client,http-status-code-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.enviro

每当我向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.
导入操作系统 >>>从google.cloud导入translate_v2作为translate >>>源语言代码='nl' >>>目标语言代码='en' >>>os.environ['GOOGLE\u应用程序\u凭据'] “/home/Documents/translate/[…keyfilename…].json” >>>txt=打开(如果为'r')。读取() >>>txt[-10:] “tuurlijk。\n” >>>translator=translate.Client() >>>翻译(txt,源语言=源语言代码,目标语言=目标语言代码) 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 文件“/home/yoozer/anaconda3/lib/python3.7/site packages/google/cloud/translate_v2/client.py”,第268行,在translate中 响应=self.\u connection.api\u请求(method=“POST”,path=”“,data=data) api请求中的文件“/home/yoozer/anaconda3/lib/python3.7/site packages/google/cloud/_http.py”,第393行 引发异常。从\u http\u响应(响应) google.api_core.exceptions.ServiceUnavailable:503 POSThttps://translation.googleapis.com/language/translate/v2: 该服务此时不可用。
这里的代码没有问题。HTTP 503表示服务在服务请求时存在问题。过一段时间你应该试试

如果你看一下503的列表,上面写着:

由于发生错误,服务器当前无法处理该请求 临时超载或定期维护,可能 经过一段时间的拖延,情况有所缓解


罐头上就是这么写的。但这已经持续了12个小时。服务器没有关闭。只是没有授权我的请求授权不应该给你503。我自己试过这个样品,它对我有效。您可以从Cloud Shell尝试此操作吗?您可以仔细检查用于执行请求的服务帐户角色。尝试使用Project>Editor角色,并确保GOOGLE_应用程序_凭据为env。变量具有指向JSON键的正确路径。但是,正如Kunai所说,这显然与服务可用性有关。您可以尝试的另一件事是向服务发出cURL请求,以便放弃客户机库层。