0

When I run code for google cloud natural language using python on local system , code is execute successfully , but When I run the same code on some network restrictions(may be office network), it show me error. I already created google service account and enabled google cloud language API.

Error: Contiue show like this E0430 10:49:06.368000000 7700 src/core/tsi/ssl_transport_security.cc:1504] Handshake failed with fatal error SSL_ERROR_SSL: error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED.

Code :

from google.cloud import language_v1
client = language_v1.LanguageServiceClient.from_service_account_json("json file path")
text = "Hello, world!"
document = language_v1.Document(content=text, type_=language_v1.Document.Type.PLAIN_TEXT)
sentiment = client.analyze_sentiment(request={"document": document}).document_sentiment
print("Text: {}".format(text))
print("Sentiment: {}, {}".format(sentiment.score, sentiment.magnitude))

When I force to stop execution it show like this error message :

sentiment = client.analyze_sentiment(request={"document": document}).document_sentiment File "google_sentiment_analysis\sent_venv\lib\site-packages\google\cloud\language_v1\services\language_service\client.py", line 477, in analyze_sentiment response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) File "google_sentiment_analysis\sent_venv\lib\site-packages\google\api_core\gapic_v1\method.py", line 154, in call return wrapped_func(*args, **kwargs) File "google_sentiment_analysis\sent_venv\lib\site-packages\google\api_core\retry.py", line 283, in retry_wrapped_func return retry_target( File "google_sentiment_analysis\sent_venv\lib\site-packages\google\api_core\retry.py", line 205, in retry_target raise exceptions.RetryError( google.api_core.exceptions.RetryError: Deadline of 600.0s exceeded while calling target function, last exception: 503 failed to connect to all addresses

Please tell me what type of permission is required in google cloud or anything else? Thanks.

2
  • At what line do you get this error? Commented Apr 30, 2022 at 5:37
  • 5th line show me error. Commented Apr 30, 2022 at 5:50

1 Answer 1

0

Just a typo. This:

client = language_v1.LanguageServiceClient.from_service_account_json("json file path")

Should be this:

client = language_v1.LanguageServiceClient().from_service_account_json("json file path")
Sign up to request clarification or add additional context in comments.

1 Comment

Error in 5th line : Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the application. For more information, please see cloud.google.com/docs/authentication/getting-started

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.