title: Different ways of setting environment variables in Jupyter notebook
body: <p>For some context, I am using Jupyter notebook on a Windows 10 machine and I want to authenticate myself into GCP by setting the environment variable &quot;GOOGLE_APPLICATION_CREDENTIALS&quot;.</p>
  <p>I was wondering, what is the difference between the two ways of setting environment variables? The first approach works when I try to access Big Query but the second doesn't.</p>
  <p>First approach,</p>
  <pre><code>import os
  os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = 'path-to-json-file-windows-style-dir'
  </code></pre>
  <p>Second approach using magic command,</p>
  <pre><code>%env GOOGLE_APPLICATION_CREDENTIALS=&quot;path-to-json-file-windows-style-dir&quot;
  </code></pre>
  <p>When I attempt to use the env variable after setting it using the second method I get the error</p>
  <pre><code>DefaultCredentialsError: File path-to-json-file-windows-style-dir was not found.
  </code></pre>
  <p>which is weird because the error is printing out the correct value of the environment variable and the path is correct.</p>
  <p>This is the code I used for access data from Big Query which is taken directly from Google's documentation:</p>
  <pre><code>from google.cloud import bigquery
  
  client = bigquery.Client()
  
  # Perform a query.
  QUERY = (
      'SELECT name FROM `bigquery-public-data.usa_names.usa_1910_2013` '
      'WHERE state = &quot;TX&quot; '
      'LIMIT 100')
  query_job = client.query(QUERY)  # API request
  rows = query_job.result()  # Waits for query to finish
  
  for row in rows:
      print(row.name)
  </code></pre>