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 script I include:

import paho.mqtt.client as mqtt

In my log:

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

perfect, thanks!

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