MQTT with Python Script component

I wish to use the new python_script component in 0.47.0 to post an image by MQTT. I am getting an error when in my hello_world.py script I include:

import paho.mqtt.client as mqtt

In my log:

2017-06-20 04:37:20 ERROR (Thread-3) [homeassistant.components.python_script.hello_world.py] Error executing script: __import__ not found
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/python_script.py", line 106, in execute
    exec(compiled.code, restricted_globals, local)
  File "hello_world.py", line 5, in <module>
ImportError: __import__ not found

I presume I need to pass the MQTT object to the script somehow, rather than importing?

I have the same problem with import requests and import time: could it be a side-effect of sandboxing?

Same problem to me…

Imports are not supported. If you want to depend on other packages, please write a custom component.

Here is a simple example of a component that exposes a service: https://github.com/home-assistant/example-custom-config/blob/master/custom_components/expose_service_sync.py

perfect, thanks!

Or use appdaemon, which is an ordinary Python script so you can do any Python code with it.