title: Set GOOGLE_APPLICATION_CREDENTIALS in Python project to use Google API
body: <p>I am a programming beginner and thing I'm trying to learn how to use google API with <code>Python</code>.</p>
  
  <p>I have:</p>
  
  <ol>
  <li>created a project on Google Cloud and enabled the API that I want to use, <code>Natural Language API</code>.</li>
  <li>created a credential and downloaded the credential JSON file, saved it as <code>apikey.JSON</code></li>
  <li>In the Terminal I have ran this command: export <code>GOOGLE_APPLICATION_CREDENTIALS=apikey.JSON</code>, no error popped.</li>
  </ol>
  
  <p>However, even when I ran the simplest of codes for this, I have errors which says the credential variable is not found. </p>
  
  <p>I am not sure what to do now. Please kindly help.</p>
  
  <p><strong>This is my code:</strong></p>
  
  <pre><code>from google.cloud import language
  
  def sentiment_text(text):
  
      client = language.LanguageServiceClient()
  
      sentiment = client.analyze_sentiment(text).document_sentiment
  
      print('Score: {}'.format(sentiment.score))
      print('Magnitude: {}'.format(sentiment.magnitude))
  
  sampletxt='Python is great'
  
  sentiment_text(sampletxt)
  </code></pre>
  
  <p><strong>And I have errors:</strong></p>
  
  <pre><code>&gt; Traceback (most recent call last):   File
  &gt; "/Users/YELI1/Downloads/googlecloud/sentimentanalysis/simple.py", line
  &gt; 21, in &lt;module&gt;
  &gt;     sentiment_text(sampletxt)
  &gt; 
  &gt;   File
  &gt; "/Users/YELI1/Downloads/googlecloud/sentimentanalysis/simple.py", line
  &gt; 5, in sentiment_text
  &gt;     client = language.LanguageServiceClient()
  &gt; 
  &gt;   File
  &gt; "/usr/local/lib/python3.6/site-packages/google/cloud/gapic/language/v1/language_service_client.py",
  &gt; line 147, in __init__
  &gt;     ssl_credentials=ssl_credentials)
  &gt; 
  &gt;   File "/usr/local/lib/python3.6/site-packages/google/gax/grpc.py",
  &gt; line 106, in create_stub
  &gt; 
  &gt;     credentials = _grpc_google_auth.get_default_credentials(scopes)   File
  &gt; "/usr/local/lib/python3.6/site-packages/google/gax/_grpc_google_auth.py",
  &gt; line 62, in get_default_credentials
  &gt;     credentials, _ = google.auth.default(scopes=scopes)
  &gt; 
  &gt;   File
  &gt; "/usr/local/lib/python3.6/site-packages/google/auth/_default.py", line
  &gt; 282, in default
  &gt; 
  &gt;     raise exceptions.DefaultCredentialsError(_HELP_MESSAGE) google.auth.exceptions.DefaultCredentialsError: Could not
  &gt; automatically determine credentials. Please set
  &gt; GOOGLE_APPLICATION_CREDENTIALS or explicitly create credential and
  &gt; re-run the application. For more information, please see
  &gt; https://developers.google.com/accounts/docs/application-default-credentials.
  </code></pre>
  
  <p>The value is not in the environment</p>
  
  <pre><code>import os 
  print(os.environ['GOOGLE_APPLICATION_CREDENTIALS']) 
     File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework‌​/Versions/3.6/lib/py‌​thon3.6/os.py", line 669, in getitem  
  raise KeyError(key) from None KeyError: 'GOOGLE_APPLICATION_CREDENTIALS'
  </code></pre>