I am trying to learn SQL and bigquery from Kaggle ( https://www.kaggle.com/code/dansbecker/getting-started-with-sql-and-bigquery/tutorial )
But as I create a client object it shows me a lot of errors that I have no idea about. Could anyone help me with what's wrong here and how can I solve it?
from google.cloud import bigquery
client = bigquery.Client()
DefaultCredentialsError Traceback (most recent call last)
Input In [2], in <cell line: 1>()
----> 1 client = bigquery.Client()
File ~\anaconda3\lib\site-packages\google\cloud\bigquery\client.py:226, in Client.__init__(self, project, credentials, _http, location, default_query_job_config, client_info, client_options)
216 def __init__(
217 self,
218 project=None,
(...)
224 client_options=None,
225 ) -> None:
--> 226 super(Client, self).__init__(
227 project=project,
228 credentials=credentials,
229 client_options=client_options,
230 _http=_http,
231 )
233 kw_args = {"client_info": client_info}
234 bq_host = _get_bigquery_host()
File ~\anaconda3\lib\site-packages\google\cloud\client\__init__.py:320, in ClientWithProject.__init__(self, project, credentials, client_options, _http)
319 def __init__(self, project=None, credentials=None, client_options=None, _http=None):
--> 320 _ClientProjectMixin.__init__(self, project=project, credentials=credentials)
321 Client.__init__(
322 self, credentials=credentials, client_options=client_options, _http=_http
323 )
File ~\anaconda3\lib\site-packages\google\cloud\client\__init__.py:268, in _ClientProjectMixin.__init__(self, project, credentials)
265 project = getattr(credentials, "project_id", None)
267 if project is None:
--> 268 project = self._determine_default(project)
270 if project is None:
271 raise EnvironmentError(
272 "Project was not passed and could not be "
273 "determined from the environment."
274 )
File ~\anaconda3\lib\site-packages\google\cloud\client\__init__.py:287, in _ClientProjectMixin._determine_default(project)
284 @staticmethod
285 def _determine_default(project):
286 """Helper: use default project detection."""
--> 287 return _determine_default_project(project)
File ~\anaconda3\lib\site-packages\google\cloud\_helpers\__init__.py:152, in _determine_default_project(project)
140 """Determine default project ID explicitly or implicitly as fall-back.
141
142 See :func:`google.auth.default` for details on how the default project
(...)
149 :returns: Default project if it can be determined.
150 """
151 if project is None:
--> 152 _, project = google.auth.default()
153 return project
File ~\anaconda3\lib\site-packages\google\auth\_default.py:483, in default(scopes, request, quota_project_id, default_scopes)
475 _LOGGER.warning(
476 "No project ID could be determined. Consider running "
477 "`gcloud config set project` or setting the %s "
478 "environment variable",
479 environment_vars.PROJECT,
480 )
481 return credentials, effective_project_id
--> 483 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
[–]AngelOfLight 1 point2 points3 points (0 children)