The executable path is different from the module location path. So I worked with virtualenv and it's ok now.
On Tuesday, April 14, 2020 at 8:39:17 PM UTC+2, Jam Volkov wrote: > > I would like to send data from Google vm instance to Google Pub/Sub using > Ansible. > Ansible playbook > > --- > - hosts: localhost > tasks: > > - name: Write into log file > local_action: > shell echo "Hello" >> /etc/ansible/log.txt > > - name: Send message through pubsub > shell: python pub.py project-344421 topic_test > args: > chdir: /home/pubsub > > Error > > "msg": "non-zero return code", > "rc": 1, > "start": "2020-04-14 18:20:00.723265", > "stderr": "Traceback (most recent call last):\n File \"pub.py\", line > 22, in <module>\n from google.cloud import pubsub_v1\nImportError: No > module named google.cloud", > "stderr_lines": [ > "Traceback (most recent call last):", > " File \"pub.py\", line 22, in <module>", > " from google.cloud import pubsub_v1", > "ImportError: No module named google.cloud" > ], > "stdout": "", > "stdout_lines": [] > > > Manually, the script pub.py runs properly with python pub.py > project-344421 topic_test > > Output > > der_topic > Published message Hello > now has message ID 874436722336138 > Published 1 message(s). > > > The modules google.cloud, google-cloud-pubsub and google-auth are installed > > pip install --upgrade google-cloud > pip install --upgrade google-cloud-pubsub > pip install --upgrade google-auth > > > > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/522637d1-292e-475b-a512-36e920ed519a%40googlegroups.com.
