All Apps and Add-ons

How to import non native python libraries like pyMC in Splunk?

MousumiChowdhur
Contributor

Hi,

I am working on building some Bayesian model in Splunk which requires non native libraries to be imported like pyMC.
Has anyone tried out something like this and help me with ways to achieve this in Splunk? Also, I would like to know in which directory can I find the native libraries in PSC add-on.
Splunk version 7.1.2
ML Toolkit version 3.4
PSC version 1.3

Thanks!

badarsebard
Communicator

This question has been asked in various ways over the years and the answer in the past has inevitably been some variant of "bundle the library in your app". There are numerous reasons these solutions are problematic and I encourage you to read through some of the past answers to better understand.

However, driven by the desire to solve this problem for myself, I've recently released a new app on Splunkbase called PyDen which allows a developer to create Python virtual environments of varying versions (2.7, 3.5-3.7) and install PyPI packages to them for use by other Python scripts. Scripts will run under these virtual environments instead of the built-in Python Splunk uses allowing you to leverage any version of Python and libraries you'd like.

The app is still in early development and I'm looking for feedback so please let me know if it satisfies your needs!

VatsalJagani
SplunkTrust
SplunkTrust

Hi @MousumiChowdhury,
If you need to download third-party library in your case pyMC and you need to put that within, $SPLUNK_HOME$/etc/app//bin , if you want to use throughout multiple apps you can use $SPLUNK_HOME$/Python-2.7/Lib/site-packages.

Directory for third-party library needs to have __init__.py file, then you can import that with just writing import pyMC.
I'm assuming directory library is having name pyMC and it had init file.

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...