Splunk Dev

splunk sdk for python : splunk.Intersplunk module not found

brdr
Contributor

Hi Splunk,

I'm getting an error after installing splunk sdk for python. The error is:

Traceback (most recent call last):
File "./shelltest.py", line 4, in
import splunk.Intersplunk
ImportError: No module named splunk.Intersplunk

I can see the splunk.Intersplunk module in dir:
/apps/splunk/lib/python2.7/site-packages/splunk

The program is basic:

!/usr/bin/env python

import sys
import subprocess
import splunk.Intersplunk
cmdargs = str(sys.argv)
program_name = "/lm_tmp/yourscript.sh"
subprocess.call([program_name, cmdargs])

PYTHONPATH variable in .bash_profile is:
PYTHONPATH=/apps/splunk/etc/apps/splunk-sdk-python

NOTE, if i replace import splunk.Intersplunk with import splunklib the program runs without any issue.

Is there something wrong with python path? Anyone, been at it for awhile and currently stumped.

Thx

Labels (2)
0 Karma

manjunathmeti
SplunkTrust
SplunkTrust

You need to use export PYTHONPATH so that this variable get passed to the child process called (to run program_name) in your script. Export PYTHONPATH instead just setting it in .bash_profile.

export PYTHONPATH=/apps/splunk/etc/apps/splunk-sdk-python
0 Karma
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 ...