Splunk Dev

How to import custom python module inside app?

seva98
Path Finder

I have tried importing Python Docx module inside my app, I have uploaded it to .../appname/lib folder and my script inside .../appname/bin couldn't find it.

Can anyone please share an example on how to upload module to app and import it in python script?

Labels (3)
Tags (2)
0 Karma
1 Solution

seva98
Path Finder

Found what was an issue, I had to move splunklib folder to .../appname/bin folder and move Python Docx module to .../appname/bin/docx and then use

import sys
sys.path.append('./docx')
sys.path.insert(0, './docx')

View solution in original post

0 Karma

seva98
Path Finder

Found what was an issue, I had to move splunklib folder to .../appname/bin folder and move Python Docx module to .../appname/bin/docx and then use

import sys
sys.path.append('./docx')
sys.path.insert(0, './docx')
0 Karma
Get Updates on the Splunk Community!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...