No module named paho mqtt

I’ve tried to build my first app and have several problems. The app should send a message to another mosquitto server. The intants and the slots works and gave out the right synonyms. Now I’ve tried to build an own action in python3 code. This doesn’t work. The output on samwatch is:

Nov 16 18:06:17 raspberrypi snips-skill-server[3524]: INFO:snips_skill_server_lib::runner : [smarthomeng-paho_test_1-smarthomeng.paho_test][err] import paho.mqtt.client as mqtt
Nov 16 18:06:17 raspberrypi snips-skill-server[3524]: INFO:snips_skill_server_lib::runner : [smarthomeng-paho_test_1-smarthomeng.paho_test][err] ImportError: No module named ‘paho’
Nov 16 18:06:22 raspberrypi snips-dialogue[3519]: INFO:snips_dialogue_lib::coordinator::coordinator: Session [76b0f751-9a85-412e-a346-cd865a16cdc2]: closing session which was active: Timeout { component: Some(ClientApp) }
Nov 16 18:06:22 raspberrypi snips-dialogue[3519]: INFO:snips_dialogue_lib::coordinator::coordinator: Site [default]: reset site -> turn off ASR and turn on Hotword
Nov 16 18:06:22 raspberrypi snips-hotword[3532]: INFO:snips_hotword_lib::audio : Audio thread for site default started.

It doesn’t run the code
In syslog came this:

Nov 16 18:06:17 raspberrypi snips-tts[3506]: INFO:snips_tts_hermes: Received a play finished message from audio server with an unknown id ‘2c6ebc67-8abf-403e-b037-f12f891d15cf’. Ignoring it.
Nov 16 18:06:17 raspberrypi snips-skill-server[3524]: INFO:snips_skill_server_lib::runner : [smarthomeng-paho_test_1-smarthomeng.paho_test][err] Traceback (most recent call last):
Nov 16 18:06:17 raspberrypi snips-skill-server[3524]: INFO:snips_skill_server_lib::runner : [smarthomeng-paho_test_1-smarthomeng.paho_test][err] File “_ctypes/callbacks.c”, line 234, in ‘calling callback function’
Nov 16 18:06:17 raspberrypi snips-skill-server[3524]: INFO:snips_skill_server_lib::runner : [smarthomeng-paho_test_1-smarthomeng.paho_test][err] File “/var/lib/snips/skills/smarthomeng.paho_test/venv/lib/python3.5/site-packages/hermes_python/ffi/wrappers.py”, line 61, in convert_arguments_when_invoking_function
Nov 16 18:06:17 raspberrypi snips-skill-server[3524]: INFO:snips_skill_server_lib::runner : [smarthomeng-paho_test_1-smarthomeng.paho_test][err] return func(hermes_client, *parsed_args)
Nov 16 18:06:17 raspberrypi snips-skill-server[3524]: INFO:snips_skill_server_lib::runner : [smarthomeng-paho_test_1-smarthomeng.paho_test][err] File “./action-smarthomeng-paho_test_1-smarthomeng.paho_test.py”, line 29, in subscribe_intent_callback
Nov 16 18:06:17 raspberrypi snips-skill-server[3524]: INFO:snips_skill_server_lib::runner : [smarthomeng-paho_test_1-smarthomeng.paho_test][err] action_wrapper(hermes, intentMessage, conf)
Nov 16 18:06:17 raspberrypi snips-skill-server[3524]: INFO:snips_skill_server_lib::runner : [smarthomeng-paho_test_1-smarthomeng.paho_test][err] File “./action-smarthomeng-paho_test_1-smarthomeng.paho_test.py”, line 42, in action_wrapper
Nov 16 18:06:17 raspberrypi snips-skill-server[3524]: INFO:snips_skill_server_lib::runner : [smarthomeng-paho_test_1-smarthomeng.paho_test][err] import paho.mqtt.client as mqtt
Nov 16 18:06:17 raspberrypi snips-skill-server[3524]: INFO:snips_skill_server_lib::runner : [smarthomeng-paho_test_1-smarthomeng.paho_test][err] ImportError: No module named ‘paho’
Nov 16 18:06:22 raspberrypi snips-dialogue[3519]: INFO:snips_dialogue_lib::coordinator::coordinator: Session [76b0f751-9a85-412e-a346-cd865a16cdc2]: closing session which was active: Timeout { component: Some(ClientApp) }
Nov 16 18:06:22 raspberrypi snips-dialogue[3519]: INFO:snips_dialogue_lib::coordinator::coordinator: Site [default]: reset site -> turn off ASR and turn on Hotword

I’ve installed paho-mqtt with
pip install paho_mqtt / pip3 install paho_mqtt / npm install -g mqtt

I only want to run a simple script to Test the Connection, hrer is my action

import paho.mqtt.client as mqtt
broker_address=“192.168.178.8”
client = mqtt.Client()
client.connect(broker_address)
client.publish(“eg/wohnen/licht/decke/schalten”,“ON”)
mqtt.loop_forever()

hope this is the right part of the forum

I hope I found the problem:

https://docs.snips.ai/articles/console/actions/actions/code-your-action/manual-action

Let’s test this. Install the paho-mqtt dependency. For this we recommend using a virtualenv

I opend virtualenv and run pip list - and there is no paho. The new problem: I can’t install it
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Keine Berechtigung: ‘/var/lib/snips/skills/smarthomeng.Licht-an-aus-dim/venv/lib/python3.5/site-packages/paho_mqtt-1.5.0.dist-info’
Consider using the --user option or check the permissions.
I can’t install paho in virtualenv

Hey, did you add paho-mqtt to the requirements.txt file? SAM will execute the setup.sh file and install these dependecies automatically if you have the code in setup.sh.

Thanks for your response, I didn’t knew this, but I found the solution step by step.
It was a little bit confusing. I opend the virtual Environment and pip3 list gave missing paho-mqtt but pip3 install paho-mqtt doesn’t Install it. It only works with the pip3 of the virtual env under venv/bin/pip3
I’ve learned about virtual env’s ans understand the working of snips a little bit more.
Now I’m in my way to learn parsing to make mqtt send the right action