Skip to main content
deleted 1 character in body
Source Link
ScottMcC
  • 4.5k
  • 1
  • 32
  • 39

Your need to set an environment variable for GOOGLE_APPLICATION_CREDENTIALS

You can add this in your code by adding in the following lines:

credential_path = "D:\Summer Projects\Translate\social media analysis-2a59d94ba22d.json" os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = credential_path 

Complete solution:

# Imports the Google Cloud client library import os from google.cloud import translate credential_path = "D:\Summer Projects\Translate\social media analysis-2a59d94ba22d.json" os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = crendential_pathcredential_path # Instantiates a client translate_client = translate.Client() # The text to translate text = u'Hello, world!' # The target language target = 'ru' # Translates some text into Russian translation = translate_client.translate( text, target_language=target) print(u'Text: {}'.format(text)) print(u'Translation: {}'.format(translation['translatedText'])) 

Your need to set an environment variable for GOOGLE_APPLICATION_CREDENTIALS

You can add this in your code by adding in the following lines:

credential_path = "D:\Summer Projects\Translate\social media analysis-2a59d94ba22d.json" os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = credential_path 

Complete solution:

# Imports the Google Cloud client library import os from google.cloud import translate credential_path = "D:\Summer Projects\Translate\social media analysis-2a59d94ba22d.json" os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = crendential_path # Instantiates a client translate_client = translate.Client() # The text to translate text = u'Hello, world!' # The target language target = 'ru' # Translates some text into Russian translation = translate_client.translate( text, target_language=target) print(u'Text: {}'.format(text)) print(u'Translation: {}'.format(translation['translatedText'])) 

Your need to set an environment variable for GOOGLE_APPLICATION_CREDENTIALS

You can add this in your code by adding in the following lines:

credential_path = "D:\Summer Projects\Translate\social media analysis-2a59d94ba22d.json" os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = credential_path 

Complete solution:

# Imports the Google Cloud client library import os from google.cloud import translate credential_path = "D:\Summer Projects\Translate\social media analysis-2a59d94ba22d.json" os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = credential_path # Instantiates a client translate_client = translate.Client() # The text to translate text = u'Hello, world!' # The target language target = 'ru' # Translates some text into Russian translation = translate_client.translate( text, target_language=target) print(u'Text: {}'.format(text)) print(u'Translation: {}'.format(translation['translatedText'])) 
Typo edit.
Source Link
dsesto
  • 8.2k
  • 3
  • 35
  • 52

Your need to set an environment variable for GOOGLE_APPLICATION_CREDENTIALS

You can add this in your code by adding in the following lines:

credential_path = "D:\Summer Projects\Translate\social media analysis-2a59d94ba22d.json" os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = crendential_pathcredential_path 

Complete solution:

# Imports the Google Cloud client library import os from google.cloud import translate credential_path = "D:\Summer Projects\Translate\social media analysis-2a59d94ba22d.json" os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = crendential_path # Instantiates a client translate_client = translate.Client() # The text to translate text = u'Hello, world!' # The target language target = 'ru' # Translates some text into Russian translation = translate_client.translate( text, target_language=target) print(u'Text: {}'.format(text)) print(u'Translation: {}'.format(translation['translatedText'])) 

Your need to set an environment variable for GOOGLE_APPLICATION_CREDENTIALS

You can add this in your code by adding in the following lines:

credential_path = "D:\Summer Projects\Translate\social media analysis-2a59d94ba22d.json" os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = crendential_path 

Complete solution:

# Imports the Google Cloud client library import os from google.cloud import translate credential_path = "D:\Summer Projects\Translate\social media analysis-2a59d94ba22d.json" os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = crendential_path # Instantiates a client translate_client = translate.Client() # The text to translate text = u'Hello, world!' # The target language target = 'ru' # Translates some text into Russian translation = translate_client.translate( text, target_language=target) print(u'Text: {}'.format(text)) print(u'Translation: {}'.format(translation['translatedText'])) 

Your need to set an environment variable for GOOGLE_APPLICATION_CREDENTIALS

You can add this in your code by adding in the following lines:

credential_path = "D:\Summer Projects\Translate\social media analysis-2a59d94ba22d.json" os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = credential_path 

Complete solution:

# Imports the Google Cloud client library import os from google.cloud import translate credential_path = "D:\Summer Projects\Translate\social media analysis-2a59d94ba22d.json" os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = crendential_path # Instantiates a client translate_client = translate.Client() # The text to translate text = u'Hello, world!' # The target language target = 'ru' # Translates some text into Russian translation = translate_client.translate( text, target_language=target) print(u'Text: {}'.format(text)) print(u'Translation: {}'.format(translation['translatedText'])) 
Source Link
ScottMcC
  • 4.5k
  • 1
  • 32
  • 39

Your need to set an environment variable for GOOGLE_APPLICATION_CREDENTIALS

You can add this in your code by adding in the following lines:

credential_path = "D:\Summer Projects\Translate\social media analysis-2a59d94ba22d.json" os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = crendential_path 

Complete solution:

# Imports the Google Cloud client library import os from google.cloud import translate credential_path = "D:\Summer Projects\Translate\social media analysis-2a59d94ba22d.json" os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = crendential_path # Instantiates a client translate_client = translate.Client() # The text to translate text = u'Hello, world!' # The target language target = 'ru' # Translates some text into Russian translation = translate_client.translate( text, target_language=target) print(u'Text: {}'.format(text)) print(u'Translation: {}'.format(translation['translatedText']))