Splunk Search

How to force Splunk to use Python 3 for our app?

dgriffioen
Engager

We build our own app that only works in Python 3. I would like to know how to force Splunk to use python 3 for this app. We don't want to ask users to change the system wide setting in server.conf. The app adds a new input form to Splunk under local inputs. Below is the error i`m getting.

"Unable to initialize modular input "appname" defined in the app "appname": Introspecting scheme=appApi: script running failed (exited with code 1).."

I tried adding python.version = python3 in inputs.conf, app.conf and props.conf but that does not fix it. Any idea how to fix this? or can it only be fixed by making the script compatible with python2?

0 Karma

richgalloway
SplunkTrust
SplunkTrust

The file in which to put python.version = python3 depends on how your app uses Python. See https://docs.splunk.com/Documentation/Splunk/8.0.3/Python3Migration/ChangesEnterprise#Python_interpr....

Of course, changing a .conf file requires restarting Splunk for the change to take effect.

---
If this reply helps you, Karma would be appreciated.

dgriffioen
Engager

The app adds a new input form to Splunk under local inputs. Below is the error i`m getting.

"Unable to initialize modular input "appname" defined in the app "appname": Introspecting scheme=appApi: script running failed (exited with code 1).."

I tried adding python.version = python3 in inputs.conf, app.conf and props.conf but that does not fix it. Any idea how to fix this? or can it only be fixed by making the script compatible with python2?

0 Karma

isoutamo
SplunkTrust
SplunkTrust

Hi

Is your splunk version 7 or 8?

R. Ismo

0 Karma

dgriffioen
Engager

We use Splunk 8. If i add python3 in server.conf everything works fine but i dont want to force python3 for the whole server, just for the app.

0 Karma

isoutamo
SplunkTrust
SplunkTrust

Did this help?

If your script is specified with #! /usr/bin/env python, then python.version will be ignored for coldToFrozen. Also note that for warmToCold, this is always how the Python script is specified, so there is no applicable python.version for warmToCold.

So try to specify path to python3 on the shebang.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Agentic Operations Start with Context: Build the Right Data Foundation

Agentic Operations Start with Context: Build the Right Data Foundation   By Courtney Wright, Product Marketing ...

Assisted, Augmented or Agentic? Choose Your Splunk Starting Point

Assisted, Augmented or Agentic? Choose Your Splunk Starting Point   By Courtney Wright, Product Marketing ...

Session 2 | Beyond the Thread: Operationalizing AI with Confidence

Session 2   Beyond the Thread: Operationalizing AI with Confidence    The true power of the Cisco Data Fabric ...