Splunk Dev

Adding external library to custom app

tmontney
Builder

I would like to use https://pypi.org/project/keyring/ in my custom app. I've been able to do it on Linux but unable to on Windows.

I need pip to install it. I tried calling python from the Splunk provided one, but it won't work. I ended up installing the latest Python on my server to pull it. Even when installed and I install keyring, it can't be found. I've tried using sys.path.append but has not helped. I've tried placing the downloaded package (from C:\Users\{username}\AppData\Local\Programs\Python\Python39\Lib\site-packages) in my bin folder.

When I run splunk cmd python myscript.py, I get

Traceback (most recent call last):
File "C:\Program Files\Splunk\etc\apps\customapp1\bin\myscript.py", line 10, in <module>
import keyring
File "C:\Program Files\Splunk\etc\apps\customapp1\bin\keyring\__init__.py", line 1, in <module>
from .core import (
File "C:\Program Files\Splunk\etc\apps\customapp1\bin\keyring\core.py", line 10, in <module>
from . import backend
File "C:\Program Files\Splunk\etc\apps\customapp1\bin\keyring\backend.py", line 42
class KeyringBackend(metaclass=KeyringBackendMeta):
^
SyntaxError: invalid syntax

I'll also note that splunk cmd python myscript.py only works if I specify the scripts full path. (This has no trouble on my Linux one.) Otherwise, I get python: can't open file 'myscript.py': [Errno 2] No such file or directory. I have a Windows environment variable named "SPLUNK_HOME" set to "C:\Program Files\Splunk".

Labels (2)
0 Karma
Get Updates on the Splunk Community!

Aligning Observability Costs with Business Value: Practical Strategies

 Join us for an engaging Tech Talk on Aligning Observability Costs with Business Value: Practical ...

Mastering Data Pipelines: Unlocking Value with Splunk

 In today's AI-driven world, organizations must balance the challenges of managing the explosion of data with ...

Splunk Up Your Game: Why It's Time to Embrace Python 3.9+ and OpenSSL 3.0

Did you know that for Splunk Enterprise 9.4, Python 3.9 is the default interpreter? This shift is not just a ...