0

I was following Google's BigQuery get started page on how to set the credentials, but something is still incorrect. These are the steps I followed:

  1. Set up a free Service Account and created my key. Saved it to a folder.

  2. Set the environment variable in Anaconda Prompt as set GOOGLE_APPLICATION_CREDENTIALS=C:\Users\$Name\OneDrive\Templates\api\BigQuery\creds.json.

  3. In Python:

    from google.cloud import bigquery

    client = bigquery.Client()

This resulted in the following error. How do I fix it?

Traceback (most recent call last):
File "<ipython-input-2-490cf645c3eb>", line 1, in <module>
client = bigquery.Client()

  File "C:\Users\$Name\Anaconda3\lib\site-packages\google\cloud\bigquery\client.py", line 179, in __init__
    project=project, credentials=credentials, _http=_http

  File "C:\Users\$Name\Anaconda3\lib\site-packages\google\cloud\client.py", line 226, in __init__
    _ClientProjectMixin.__init__(self, project=project)

  File "C:\Users\$Name\Anaconda3\lib\site-packages\google\cloud\client.py", line 178, in __init__
    project = self._determine_default(project)

  File "C:\Users\$Name\Anaconda3\lib\site-packages\google\cloud\client.py", line 193, in _determine_default
    return _determine_default_project(project)

  File "C:\Users\$Name\Anaconda3\lib\site-packages\google\cloud\_helpers.py", line 186, in _determine_default_project
    _, project = google.auth.default()

  File "C:\Users\$Name\Anaconda3\lib\site-packages\google\auth\_default.py", line 338, in default
    raise exceptions.DefaultCredentialsError(_HELP_MESSAGE)

DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the application. For more information, please see https://cloud.google.com/docs/authentication/getting-started
1

1 Answer 1

0

Were you running the python in the same shell as where you set the environment variable? you may need to export GOOGLE_APPLICATION_CREDENTIALS if you are running in a different shell/tab.

Sign up to request clarification or add additional context in comments.

1 Comment

For the future, questions like this one, are normally comments. I set the variable in the Anaconda prompt for my base environment. Then I restarted the environment, opened up my IDE and tried to execute it there. The instructions do not provide a non-command line option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.