I need to add a Python module that is not included in the Splunk python. I want to use this module in Django framework, but the answers in this previous question do not satisfy my requirement:
https://answers.splunk.com/answers/8/can-i-add-python-modules-to-the-splunk-environment.html
any help
To add numpy, scipy, pandas, scikit-learn, or statsmodels, there's an app on Splunkbase you can install - Python for Scientific Computing. You need to use the correct version for your OS, as many of these libraries have OS specific dependencies. Here's the Linux 64 bit link: https://splunkbase.splunk.com/app/2882/. The README in the app contains instructions on how to import the libraries into other scripts once that app is installed.
Hello, I was the same problem with Mysql module that I was install on my Centos server
Splunk didn't work with this library, because splunk has they own python library...then you can fix it only added on the begin your script all libraries of python and also you must to add the python Centos library too... as this way
[root@xxxx]#find / -name site-packages
/usr/lib/python2.7/site-packages
/usr/lib64/python2.7/site-packages
/opt/splunk/etc/apps/Splunk_SA_Scientific_Python_linux_x86_64/bin/linux_x86_64/lib/python2.7/site-packages
/opt/splunk/lib/python2.7/site-packages
[root@xxxx]# whereis python
python: /usr/bin/python2.7 /usr/bin/python /usr/lib/python2.7 /usr/lib64/python2.7 /etc/python /usr/include/python2.7 /opt/splunk/bin/python /opt/splunk/bin/python2.7 /usr/share/man/man1/python.1.gz
include all at begin your script
import sys
sys.path.append('/usr/bin/python2.7')
sys.path.append('/usr/lib/python2.7/site-packages')
sys.path.append('/usr/lib64/python2.7/site-packages')
And that's it , you can run mysql module without any problem and create your alerts with this module.
import mysql.connector
I hope that this fix will help you
Joel Urtubia Ugarte
To add numpy, scipy, pandas, scikit-learn, or statsmodels, there's an app on Splunkbase you can install - Python for Scientific Computing. You need to use the correct version for your OS, as many of these libraries have OS specific dependencies. Here's the Linux 64 bit link: https://splunkbase.splunk.com/app/2882/. The README in the app contains instructions on how to import the libraries into other scripts once that app is installed.
What if there are other python3 modules I want to add? Such as openssl, websockets? Other modules outside of scientific computing? I'm building a TA that is a wrapper for an existing python3 REST api for one of our products, I don't want to ask users to point to an alternative python3 path and script API calls to come from there, but that seems like the only choice, is there any easier way to just specify the modules I want Splunk python3 to use?
This has been awhile since there was a response to this. I am having similar problems trying to import pandas into a python script. Is there anyway we can import modules to the splunk python script?
Using the Python for Scientific Computing add-on gives me a
Traceback (most recent call last):
File "PackageCmsResults.py", line 15, in <module>
import exec_anaconda
File "/opt/splunk/etc/apps/XXXXXXXX/bin/exec_anaconda.py", line 17, in <module>
from util.base_util import get_apps_path
ModuleNotFoundError: No module named 'util'
thanks for your answer .
do you have any idea for matlab module
You have a few options:
My recommendation would be the first option. All you need to do is place your library in the same folder, and then you can simply call import from your script. import always searches the local folder in addition to any system paths.
i want to add numpy module to python in splunk ,
i follow the frist option and get the /usr/lib/python2.7/dist-package/numpy
to the bin folder of my project but it still not work .
Ah...numpy is a little more intricate. New answer forthcoming