【发布时间】:2020-10-05 15:29:35
【问题描述】:
我是编程新手,一直在尝试使用 Google Translate API。我遇到了这个问题,并试图找到无济于事的解决方案。我已经创建了一个 Google 服务帐户和密钥。我在 Jupyter Notebook 内的 Mac 上。
错误:
~/opt/anaconda3/lib/python3.7/site-packages/google/cloud/client.py in __init__(self, credentials, _http, client_options)
141 raise ValueError(_GOOGLE_AUTH_CREDENTIALS_HELP)
142
--> 143 scopes = client_options.scopes or self.SCOPE
144
145 # if no http is provided, credentials must exist
AttributeError: 'ClientOptions' object has no attribute 'scopes'
我的代码:
import os
from google.cloud import translate_v2
os.environ["GOOGLE_APPLICATION_CREDENTIALS"]="cloud_key.json"
translate_client = translate.Client()
【问题讨论】:
-
你可以查看这个帖子stackoverflow.com/a/63287810/8835357
标签: python google-api google-translate