Getting Data In

python path in script

gitingua
Communicator

Hello colleagues

I have a python file. which I add to Data inputs -> script

Set the interval, set up, the file itself works

but the initial path starts with /opt/splunk/bin/python.

 

/bin/python  /.../.../file.py

help pls!!

0 Karma

shivanshu1593
Builder

As a workaround, could you try adding the following to the script and see if it helps.

import sys
sys.path.append('/bin/splunk') #You can modify the path as per your requirement.

 

Thank you,
Shiv
###If you found the answer helpful, kindly consider upvoting/accepting it as the answer as it helps other Splunkers find the solutions to similar issues###
0 Karma

gitingua
Communicator

@shivanshu1593  not working

still starts through /opt/splunk/bin/python

0 Karma

shivanshu1593
Builder

Well, Splunk related scripts are executed from $SPLUNK_HOME/bin/python to maintain the compatibility with the environment. You can specify the libraries inside the /bin directory of your app, if you have external libraries' dependency. If sys.append.path didn't work, then unfortunately you'll have to make do with Splunk's path.

Thank you,
Shiv
###If you found the answer helpful, kindly consider upvoting/accepting it as the answer as it helps other Splunkers find the solutions to similar issues###
0 Karma

shivanshu1593
Builder

Could you elaborate your question a bit, if possible? What is it that you are seeking? The issue?

Thank you,
Shiv
###If you found the answer helpful, kindly consider upvoting/accepting it as the answer as it helps other Splunkers find the solutions to similar issues###
0 Karma

gitingua
Communicator

I need to tell the python script to run pythonpath=/bin /splunk
but not /opt/splunk/bin/splunk

@shivanshu1593 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Any Python script that Splunk runs will use the Splunk-supplied Python interpreter.  That ensures the script runs in a Splunk-compatible environment.

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

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

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...