GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — How to add the environment variables in Windows? · Issue #117 · GoogleCloudPlatform/nodejs-docs-samples

How to add the environment variables in Windows? #117

New issue
Copy link
New issue
Copy link
Closed
Closed
How to add the environment variables in Windows?#117
Copy link
Labels
🚨This issue needs some love.triage meI really want to be triaged.

Description

@paulcanning
paulcanning
opened on May 24, 2016
Issue body actions

I cannot figure out how to set the GOOGLE_APPLICATION_CREDENTIALS on Windows 10.

The documentation is pretty sparse.

I have Node setup OK, and cloned this repo.

I get the following error when running the command node recognize "resources/quit.raw"

Got audio file!
Loading speech service...
{ [Error: Google Cloud Speech API has not been used in project google.com:cloudsdktool before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/speech.googleapis.com/overview?project=google.com:cloudsdktool then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.]
code: 403,
errors:
[ { message: 'Google Cloud Speech API has not been used in project google.com:cloudsdktool before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/speech.googleapis.com/overview?project=google.com:cloudsdktool then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.',
domain: 'global',
reason: 'forbidden' } ] }

Why is it looking at the wrong project?

How do I set it to look at my project (I have a google project with speech api enabled)

Reacted by Karol Drozdowski

Activity

  1. Hgergely commented on May 24, 2016

    @Hgergely
    Hgergely
    on May 24, 2016
    More actions

    Hey Paul

    I could get it working however not on windows 10 but it should not make any
    difference
    Have you run this line ?

    export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account_file.json

    and created the right file for your application? if not go to

    https://cloud.google.com/speech/docs/auth-template/cloud-api-auth#using_the_console_name_short

    link which explains just fine how to do that. it works.

    Counter question :

    Do you have any idea when they will add wrapper for the streaming version too?

    Cheers

    Greg.

    On 24 May 2016 at 16:47, paulcanning [email protected] wrote:

    I cannot figure out how to set the GOOGLE_APPLICATION_CREDENTIALS on
    Windows 10.

    The documentation is pretty sparse.

    I have Node setup OK, and cloned this repo.

    I get the following error when running the command node recognize
    "resources/quit.raw"

    Got audio file!
    Loading speech service...
    { [Error: Google Cloud Speech API has not been used in project google.com:cloudsdktool
    before or it is disabled. Enable it by visiting
    https://console.developers.google.com/apis/api/speech.googleapis.com/overview?project=google.com:cloudsdktool
    then retry. If you enabled this API recently, wait a few minutes for the
    action to propagate to our systems and retry.]
    code: 403,
    errors:
    [ { message: 'Google Cloud Speech API has not been used in project
    google.com:cloudsdktool before or it is disabled. Enable it by visiting
    https://console.developers.google.com/apis/api/speech.googleapis.com/overview?project=google.com:cloudsdktool
    then retry. If you enabled this API recently, wait a few minutes for the
    action to propagate to our systems and retry.',
    domain: 'global',
    reason: 'forbidden' } ] }

    Why is it looking at the wrong project?

    How do I set it to look at my project (I have a google project with speech
    api enabled)

    —
    You are receiving this because you are subscribed to this thread.
    Reply to this email directly or view it on GitHub
    #117

  2. paulcanning commented on May 24, 2016

    @paulcanning
    paulcanning
    on May 24, 2016
    Author
    More actions

    export is not a Windows command. (docs only cater for linux)

    I got it working by manually adding the env variables in Windows (control panel, system, environment variables)

  3. Hgergely commented on May 24, 2016

    @Hgergely
    Hgergely
    on May 24, 2016
    More actions

    Also check this out
    http://stackoverflow.com/questions/9249830/how-can-i-set-node-env-production-in-windows

    greg

    On 24 May 2016 at 16:47, paulcanning [email protected] wrote:

    I cannot figure out how to set the GOOGLE_APPLICATION_CREDENTIALS on
    Windows 10.

    The documentation is pretty sparse.

    I have Node setup OK, and cloned this repo.

    I get the following error when running the command node recognize
    "resources/quit.raw"

    Got audio file!
    Loading speech service...
    { [Error: Google Cloud Speech API has not been used in project google.com:cloudsdktool
    before or it is disabled. Enable it by visiting
    https://console.developers.google.com/apis/api/speech.googleapis.com/overview?project=google.com:cloudsdktool
    then retry. If you enabled this API recently, wait a few minutes for the
    action to propagate to our systems and retry.]
    code: 403,
    errors:
    [ { message: 'Google Cloud Speech API has not been used in project
    google.com:cloudsdktool before or it is disabled. Enable it by visiting
    https://console.developers.google.com/apis/api/speech.googleapis.com/overview?project=google.com:cloudsdktool
    then retry. If you enabled this API recently, wait a few minutes for the
    action to propagate to our systems and retry.',
    domain: 'global',
    reason: 'forbidden' } ] }

    Why is it looking at the wrong project?

    How do I set it to look at my project (I have a google project with speech
    api enabled)

    —
    You are receiving this because you are subscribed to this thread.
    Reply to this email directly or view it on GitHub
    #117

  4. jmdobry commented on May 24, 2016

    @jmdobry
    jmdobry
    on May 24, 2016
    Member
    More actions

    Why is it looking at the wrong project?

    Make sure your GCLOUD_PROJECT environment variable is set to your Google project ID.

    Command prompt:

    set GCLOUD_PROJECT=your-project-id
    set GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account_file.json
    

    Powershell:

    $env:GCLOUD_PROJECT="your-project-id"
    $env:GOOGLE_APPLICATION_CREDENTIALS="/path/to/service_account_file.json"
    Reacted by Bommels, Anton Yakimenko, Tony Xie, Rajat Saini, Victor Gea, Cássio Farias Machado, gerblaurynas, Abhinav, visalikk, Michael and 14 more
    Reacted by visalikk, MrPeppaPig and CKC
    Reacted by D. K. Min, CKC, Amandeep Singh, Datasleek, kevin vergara muñoz, Bibek Rauniyar and Wagner Ricardo Wagner
    Reacted by kevin vergara muñoz
  5. jmdobry commented on May 25, 2016

    @jmdobry
    jmdobry
    on May 25, 2016
    Member
    More actions

    The README no has instructions for setting environment variables in windows.

  6. jmdobry
    closed this as completedon May 25, 2016
  7. sonanhson commented on Nov 19, 2017

    @sonanhson
    sonanhson
    on Nov 19, 2017
    More actions

    Hi jmdobry,

    I know this post quite old. But I have the same problem about setting environment variable as below:
    I want to use Google cloud vision API on Python. I have created a service account for authentication.
    Based on the instruction of jmdobry in this post, I set the environment variable with the following commands in cmd (Windows 7)

    set GCLOUD_PROJECT=my-project-id
    set GOOGLE_APPLICATION_CREDENTIALS=C:/Python install/Google API/filename.JSON

    Then, I run the following Python code to test the first API request:

    import io
    import os

    from google.cloud import vision
    from google.cloud.vision import types

    client = vision.ImageAnnotatorClient()

    file_name = os.path.join(
    os.path.dirname(file),
    'C:/Python install/Python Test/Photos Testing/Lobstersize.jpg')

    with io.open(file_name, 'rb') as image_file:
    content = image_file.read()

    image = types.Image(content=content)

    response = client.label_detection(image=image)
    labels = response.label_annotations

    print('Labels:')
    for label in labels:
    print(label.description)

    But, it shows an error as below:

    Traceback (most recent call last):
    File "GoogleAPI.py", line 9, in
    client = vision.ImageAnnotatorClient()
    File "C:\Python install\lib\site-packages\google\cloud\vision_v1\gapic\image_annotator_client.py", line 135, in __init
    __
    ssl_credentials=ssl_credentials)
    File "C:\Python install\lib\site-packages\google\gax\grpc.py", line 106, in create_stub
    credentials = _grpc_google_auth.get_default_credentials(scopes)
    File "C:\Python install\lib\site-packages\google\gax_grpc_google_auth.py", line 62, in get_default_credentials
    credentials, _ = google.auth.default(scopes=scopes)
    File "C:\Python install\lib\site-packages\google\auth_default.py", line 292, in default
    raise exceptions.DefaultCredentialsError(_HELP_MESSAGE)
    google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICA
    TION_CREDENTIALS or
    explicitly create credential and re-run the application. For more
    information, please see
    https://developers.google.com/accounts/docs/application-default-credentials.

    Please help me this issue.

    Thank you very much.

    Son.

    Reacted by sakthigeek
  8. sakthigeek commented on Jan 11, 2018

    @sakthigeek
    sakthigeek
    on Jan 11, 2018
    More actions

    Hi @sonanhson , I also have the same problem. I have tried setting the environment variable through the above commands and directly through control panel, but the same error persists. Is there any solution to this problem? Is there any other way I can get the vision API up and running locally?

  9. sakthigeek commented on Jan 11, 2018

    @sakthigeek
    sakthigeek
    on Jan 11, 2018
    More actions

    Hi @sonanhson, I found the solution, use the following code to add the environment variable, it works. But I don't know yet why the other approaches don't work.

    import os
    os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "path_to_your_.json_credential_file"

    This will also be useful when you are switching between projects that need different credentials.

    Reacted by Ann, islam-nassar, harshilp9, Gabriele Cimato, Dhaval Thakkar, Thomas van der Meulen, Rachel Basse, JessieD, MishalJasmine, ruchith696 and 7 more
    Reacted by harshilp9, Rachel Basse and AndySum
    Reacted by AndySum
    Reacted by Rachel Basse and AndySum
  10. Annushka34 commented on Apr 14, 2018

    @Annushka34
    Annushka34
    on Apr 14, 2018
    More actions

    it helped me)

  11. rajeshray02 commented on May 21, 2018

    @rajeshray02
    rajeshray02
    on May 21, 2018
    More actions

    Hi All,
    I need your valuable suggestion, I am using google API(Google.Cloud.Speech.V1) for voice dictation and using C# as code behind. Below is the part of Code:

    var speech = SpeechClient.Create();
    var response = speech.Recognize(new RecognitionConfig()
    {
    Encoding = RecognitionConfig.Types.AudioEncoding.Linear16,
    SampleRateHertz = 16000,
    LanguageCode = "en",
    }, RecognitionAudio.FromFile("audio.raw"));
    foreach (var result in response.Results)
    {
    foreach (var alternative in result.Alternatives)
    {
    Console.WriteLine(alternative.Transcript);
    }
    }

    but I'm getting exception "Status(StatusCode=PermissionDenied, Detail="Cloud Speech API has not been used in project 19063669187 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/speech.googleapis.com/overview?project=19063669187 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.")".

    As one suggestion is given by Hgergely is to run the below code:

    export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account_file.json

    But where I have to run this line of code. I did run in cmd but didn't work. In code behind 'export' keyword is not acceptable.

    Please do provide your valuable suggestion with clear details.
    Thanks...

  12. viv3k3y commented on Aug 21, 2019

    @viv3k3y
    viv3k3y
    on Aug 21, 2019
    More actions

    @rajeshray02 use this from command line:
    set GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account_file.json

  13. mrpeppapig commented on Dec 11, 2019

    @mrpeppapig
    mrpeppapig
    on Dec 11, 2019
    More actions

    Why is it looking at the wrong project?

    Make sure your GCLOUD_PROJECT environment variable is set to your Google project ID.

    Command prompt:

    set GCLOUD_PROJECT=your-project-id
    set GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account_file.json
    

    Powershell:

    $env:GCLOUD_PROJECT="your-project-id"
    $env:GOOGLE_APPLICATION_CREDENTIALS="/path/to/service_account_file.json"

    After all the struggles, I didn't include the $ dollar sign

  14. 99ansh commented on Mar 24, 2020

    @99ansh
    99ansh
    on Mar 24, 2020
    More actions

    export is not a Windows command. (docs only cater for linux)

    I got it working by manually adding the env variables in Windows (control panel, system, environment variables)

    I am setting it manually, still, I get the same error.

  15. yoshi-automation
    added
    🚨This issue needs some love.
    triage meI really want to be triaged.
    on Apr 7, 2020
  16. JDanielHarvey commented on May 24, 2020

    @JDanielHarvey
    JDanielHarvey
    on May 24, 2020
    More actions

    Still struggling with this myself but @sakthigeek solutions seems to have worked by setting it explicit. Interested to see if anyone else found a solution on Windows by setting it via CMD/PowerShell or through the UI of the control panel

  17. MDiakhate12 commented on Mar 18, 2021

    @MDiakhate12
    MDiakhate12
    on Mar 18, 2021
    More actions

    For Windows CMD:
    set GCLOUD_PROJECT=foobar
    set GOOGLE_APPLICATION_CREDENTIALS=path/to/your/file.json
    Important!
    I was really struggling with it since I noticed that the problem was due to double quotes
    DON'T USE Double quotes!

    Reacted by Ryan
  18. ace-n
    added a commit that references this issue on Nov 14, 2022

    chore: update sample lockfiles (#117)

    ad5a948
  19. ahrarmonsur
    added 3 commits that reference this issue on Nov 16, 2022

    Release v0.2.1 (#117)

    02d2fa6

    Release v0.2.1 (#117)

    8849c6a

    Release v0.2.1 (#117)

    8ab1e85
  20. ace-n
    added 4 commits that reference this issue on Nov 16, 2022

    chore(deps): lock file maintenance (#117)

    dff2a51

    chore(deps): lock file maintenance (#117)

    c04a374

    Release v0.2.1 (#117)

    6397357

    migrate code from googleapis/nodejs-speech (#2857)

    624d200
  21. ahrarmonsur
    added a commit that references this issue on Nov 18, 2022

    fix(samples): correct usage of toString() (#117)

    abf66f9
  22. ace-n
    added 2 commits that reference this issue on Nov 21, 2022

    chore: update sample lockfiles (#117)

    4521610

    chore: update sample lockfiles (#117)

    f57c097
  23. jsimonweb
    added a commit that references this issue on Dec 12, 2022

    chore: check all connections for io.EOF (GoogleCloudPlatform#129)

    This issue will close once commit 1a3d46b is merged into the 'master' branch.
    1a3d46b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🚨This issue needs some love.triage meI really want to be triaged.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.