1

Before calling the Jupyter Notebook, i run the below code in Terminal for Google Application Credentials :

export GOOGLE_APPLICATION_CREDENTIALS="/Users/mac/Desktop/Bigquery-Key.json"

Then set the below configuration in Jupyter Notebook :

%load_ext google.cloud.bigquery
# Imports the Google Cloud Client Library 
from google.cloud import bigquery

# Instantiates a Client for Bigquery Service
bigquery_client = bigquery.Client()

Now, i wanted to write a Python script(.py file) which will do both the tasks instead of using Terminal.

How can it be done ? Kindly advise ? Thanks

1 Answer 1

2

You can change the environment within a Python script. The environment is stored in the dictionary os.environ:

import os
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "/Users/mac/Desktop/Bigquery-Key.json"
Sign up to request clarification or add additional context in comments.

Comments

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.