【发布时间】:2018-02-20 13:35:01
【问题描述】:
我尝试运行使用 Google 云的代码。
import signal
import sys
from google.cloud import language, exceptions
# create a Google Cloud Natural Languague API Python client
client = language.LanguageServiceClient()
但它给出了以下错误消息:
Traceback (most recent call last):
File "analyse-comments.py", line 7, in <module>
client = language.LanguageServiceClient()
File "C:\Python27\lib\site-packages\google\cloud\language_v1\gapic\language_service_client.py", line 92, in __init__
scopes=self._DEFAULT_SCOPES)
File "C:\Python27\lib\site-packages\google\api_core\grpc_helpers.py", line 132, in create_channel
credentials, _ = google.auth.default(scopes=scopes)
File "C:\Python27\lib\site-packages\google\auth\_default.py", line 283, in default
raise exceptions.DefaultCredentialsError(_HELP_MESSAGE)
google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or
explicitly create credential and re-run the application. For more
information, please see
https://developers.google.com/accounts/docs/application-default-credentials.
第 7 行就是这部分代码
client = language.LanguageServiceClient()
我已经 pip install google 和 cloud。我有谷歌的解决方案,但没有一个解决方案适合我的情况需要解决的问题。
【问题讨论】:
-
你必须向 python 提供你的 google api 密钥
-
我认为还没有
-
在 google api 中,如果您创建应用程序,那么它将为您提供凭证文件。你需要整合的
-
我收到了凭证文件,但我仍然遇到同样的错误
标签: python google-cloud-platform service-accounts google-natural-language