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.

Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...