Just use the standard way of installing modules (make sure that splunk and python are in path):
splunk cmd python setup.py install
Users are free to install any python module they desire. The caveats are, 1) upgrading Splunk may break them, 2) installing newer versions of packages that come with Splunk may produce unknown interaction problems.
To install a python package in splunk:
$ splunk cmd <python_install_command>
So if the package uses the setup.py method:
$ cd path_to_package_setup $ splunk cmd python setup.py install
Or if it's an egg,
$ splunk cmd ./my-python-installer.egg
The final location of the installed modules would be:
Is that still supported with 4.1 ? I tried both ways, first one prouced errors, second one didn't produce any output and nothing was installed.
There's also a more upgrade-friendly way to accomplish this. Some of our users setup whichever script they've configured in Splunk as a pass-through to a script that runs using their system Python (with whichever custom modules they've installed).
The steps are roughly:
configure your script in splunk (search script, scripted input, whatever)
this script should:
unset PYTHONPATH (in os.environ)
perhaps unset LD_LIBRARY_PATH, depending on your environment (also in os.environ)
create a process to run /usr/bin/python (via subprocess)
redirect stdin, stdout, stderr to/from script2
script2 can then load any arbitrary python module installed in your system's python installation.
As another option I would checkout this post on how to add egg file or source files while still using Splunk python rather than system. http://answers.splunk.com/answers/220196/import-non-native-python-libraries-into-splunk.html#answer-...
Updating your Splunk Python is not supported (by Splunk). The recommended method is to update your system's Python or install a 3rd copy of Python that is not located in your PATH.
i have 3 pythons in my linux server, local 2.3, 2.5 and 2.6(in splunk4.0.8). I can not install MySQL-python-1.2.3c1 to 2.6, but it's ok to install it to local 2.3. the following is the detail.
python2.6 setup.py build ImportError: No module named setuptools
sh setuptools-0.6c11-py2.6.egg ImportError: No module named command.bdist
[root@localhost bin]# ./splunk cmd /local/dl/setuptools-0.6c11-py2.6.egg Traceback (most recent call last): File "", line 1, in File "/local/dl/setuptools-0.6c11-py2.6.egg/setuptools/init.py", line 2, in File "/local/dl/setuptools-0.6c11-py2.6.egg/setuptools/extension.py", line 2, in File "/local/dl/setuptools-0.6c11-py2.6.egg/setuptools/dist.py", line 5, in File "/local/dl/setuptools-0.6c11-py2.6.egg/setuptools/command/init.py", line 13, in ImportError: No module named command.bdist
[root@localhost bin]# ./splunk cmd /local/dl/MySQL_python-1.2.3c1-py2.6-linux-i686.egg couldn't run "/local/dl/MySQL_python-1.2.3c1-py2.6-linux-i686.egg": Exec format error
@the_wolverine, how to tell splunk to execute lookup python script with system's Python?
No, there's no way to tell splunk to run some other python. However, you can make the script itself do this as per amrit's comment.