Achim Munene
Achim Munene

Reputation: 536

Configuring Google Translate on Windows

I want to use Google Translate API in my Python application and I have read through the documentation and I have set my Service Account and downloaded the JSON file now according to the documentation I am supposed to run a:

$ export GOOGLE_APPLICATION_CREDENTIALS=<path_to_service_account_file>

Now I am doing my development on a Windows machine and I tried using the

>setx GOOGLE_APPLICATION_CREDENTIALS "<path_to_service_account_file>"

It generated a success however when I tried to create a translate object I kept getting the following error:

from google.cloud import translate
trans = translate.Client()

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\achim\Envs\expert-farmer\lib\site-packages\google\cloud\translate\client.py", line 66, in __init__
    super(Client, self).__init__(credentials=credentials, _http=_http)
  File "C:\Users\achim\Envs\expert-farmer\lib\site-packages\google\cloud\client.py", line 128, in __init__
    credentials = get_credentials()
  File "C:\Users\achim\Envs\expert-farmer\lib\site-packages\google\cloud\credentials.py", line 39, in get_credentials
    credentials, _ = google.auth.default()
  File "C:\Users\achim\Envs\expert-farmer\lib\site-packages\google\auth\_default.py", line 282, 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.

Upvotes: 1

Views: 572

Answers (1)

rmeertens
rmeertens

Reputation: 4451

The answer to your question was resolved in the comments! Next time don't use quote characters around your command.

setx GOOGLE_APPLICATION_CREDENTIALS <path_to_service_account_file>

Upvotes: 1

Related Questions