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.
Get Updates on the Splunk Community!

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...