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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...