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:
Set up a free Service Account and created my key. Saved it to a folder.
Set the environment variable in Anaconda Prompt as
set GOOGLE_APPLICATION_CREDENTIALS=C:\Users\$Name\OneDrive\Templates\api\BigQuery\creds.json
.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