1
votes

I am pretty new to Google Cloud Pub/Sub, so I am just playing around with the code that is available on the docs in order to know the service better. In this instance I am trying to execute the simple code on the official docs to publish some data into a topic. But I am encountering an issue. There is an error which states topic_path() is not a member of PublisherClient. Has anyone else faced this issue? Below is the snapshot.

enter image description here

1
Does the issue happen when you run the script from the command line? What version of Python? What version of the PubSub library? Is the code copied directly from the sample? Can't see the import because of the error message covering it.Kamal Aboul-Hosn
Please also provide a link to the docs / repo from which you are getting this snippet.Kolban
This seems to be a problem with your local environment on not recognizing the installation of pubsub library, and your IDE is showing that because 1) you didn't install all required dependencies or 2) you didn't configured your IDE to get the correct dependencies. Check if every dependencies are installed through pip install and search how to better organize your dependency manager through virtualenvmanasouza
I had not set the variable GOOGLE_APPLICATION_CREDENTIALS. So i was getting an authentication error when I was trying to execute the code from command line. After setting the variable the code runs smoothly and messages get published to the topic. However the red underline still remains below that line even though the code runs. I am using a python virtual environment in which I have installed the pubsub library via pip install. I am using that particular environment's python interpreter in my IDE. cloud.google.com/pubsub/docs/quickstart-client-libraries -- link to the google docs.Rajnil Guha

1 Answers

2
votes

The issue is that the PublisherClient instance has dynamic attributes, so pylint is unable to infer the members of the instance (I'm assuming you're using pylint based on the linting message).

You can ignore this for all google.cloud.* packages by setting this in your .pylintrc:

generated-members=google.cloud.*