ImportError cannot import name '_cloud_sdk' from 'google.auth'

612 views Asked by At

I am trying to implement a publish message from pipedream to google cloud pub/sub using python snippet. I am facing an import error named cannot import name '_cloud_sdk' from 'google.auth'.

The code snippet used is as follows :

import os
# pipedream add-package google-cloud-pubsub
from google.cloud import pubsub_v1
def handler(pd: "pipedream"):
  credentials_path =pd.steps["trigger"]["event"]
  os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = credentials_path
  publisher = pubsub_v1.PublisherClient()
  topic_path = 'projects/my-project-1909-363003/topics/my-topic'
  data = 'Msg from Pipedream'
  data = data.encode('utf-8')
  attributes = {
    'FName3': 'Acco',
  }
  future = publisher.publish(topic_path, data, **attributes)
  print(f'published message id {future.result()}')

enter image description here

0

There are 0 answers