TECHZEN Zenoss User Community ARCHIVE  

How to add required Python module to ZenPack

Subject: How to add required Python module to ZenPack
Author: Bharat Kumar Kobagana
Posted: 2018-09-05 10:29

I am creating a data source plugin. Which is a Python script.

In my Python script I am using 'requests' module. But this module is not present on ZenOSS Collectors.
So I am getting "No module found. 'requests'".

How can I solve this issue. How can I add required Python module to my ZenPack?

------------------------------
Bharat Kumar Kobagana
Visakhapatnam
------------------------------


Subject: RE: How to add required Python module to ZenPack
Author: Jane Curry
Posted: 2018-09-06 06:34

If it is a a pure Python module that you want to include with your ZenPack, you can include the .egg code in the lib directory of your ZenPack.  You then need to amend the __init__.py file in the main directory of your ZenPack, to include:

import os
import sys

libDir = os.path.join(os.path.dirname(__file__), 'lib')
if os.path.isdir(libDir):
    sys.path.append(libDir)
    for file in os.listdir(libDir):
       if file.endswith('.egg'):
           sys.path.append(os.path.join(libDir, file))

There is an example in my ZenPacks.community.VMwareESXiMonitorPython on GitHub at  https://github.com/jcurry/ZenPacks.community.VMwareESXiMonitorPython 

Cheers,
Jane

------------------------------
Jane Curry
Skills 1st United Kingdom
jane.curry@skills-1st.co.uk
------------------------------


Subject: RE: How to add required Python module to ZenPack
Author: Bharat Kumar Kobagana
Posted: 2018-09-06 23:41

Thanks a lot Jane. Will go through your ZenPack.

------------------------------
Bharat Kumar Kobagana
------------------------------


< Previous
How to make ZenPack available on all collectors
  Next
Creating ZenPack. Question from novice
>