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!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

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