StackStorm-Exchange / stackstorm-zabbix

Apache License 2.0
16 stars 21 forks source link

ImportError: No module named zabbix.api #25

Open nikolaev-rd opened 5 years ago

nikolaev-rd commented 5 years ago

To avoid this error

Traceback (most recent call last):
  File "tools/register_st2_config_to_zabbix.py", line 6, in <module>
    from zabbix.api import ZabbixAPI
ImportError: No module named zabbix.api

when execute script

/opt/stackstorm/packs/zabbix/tools/register_st2_config_to_zabbix.py

first you need to install py-zabbix python module:

pip install py-zabbix

Maybe this help somebody, I think it would be usefull to add this steps to Installation section.

Kami commented 5 years ago

As per docs, you need to use Python binary from the pack virtual environment which contains the correct dependencies.

You either need to source source /opt/stackstorm/virtualenvs/zabbix/bin/activate script first or use Python binary from that virtualenv directly:

/opt/stackstorm/virtualenvs/zabbix/bin/python /opt/stackstorm/packs/zabbix/tools/register_st2_config_to_zabbix.py

I will also update the pack documentation to make that very explicit and clear.

Kami commented 5 years ago

Hopefully this will make it more clear in the future - 163c74b777172fad3b25a5e38fa5a0a22d2a1189.

I also changed it to a single line since it's less error prone if you only copy a single line (aka you don't copy "source" line).

nikolaev-rd commented 5 years ago

In my case I execute command from Zabbix host (no one StackStorm here).