Quantcast
Channel: Questions in topic: "splunk-enterprise"
Viewing all articles
Browse latest Browse all 47296

In Splunk Enterprise, can you help me call an external Python3 via Script?

$
0
0
Splunk still uses Python 2.7 internally but has the ability to call external scripts to generate data via [Scripted Inputs](https://docs.splunk.com/Documentation/Splunk/7.1.3/AdvancedDev/ScriptedInputsIntro) I would like to pull data using an external API which has a Python 3 library. I have installed Python 3 to a separate place on the file system and written a Windows batch script, which calls this and invokes the Python 3 API. When run from the OS, this generates the data I would like, but if I try to add this batch script as an input to Splunk, I get an error along the lines of the following: ERROR ExecProcessor - message from "e:\splunk\bin\scripts\test.bat" Fatal Python error: Py_Initialize: unable to load the file system codec ERROR ExecProcessor - message from "e:\splunk\bin\scripts\test.bat" File "E:\splunk\Python-2.7\Lib\encodings\__init__.py", line 123 ERROR ExecProcessor - message from "e:\splunk\bin\scripts\test.bat" raise CodecRegistryError,\ ERROR ExecProcessor - message from "e:\splunk\bin\scripts\test.bat" ^ ERROR ExecProcessor - message from "e:\splunk\bin\scripts\test.bat" SyntaxError: invalid syntax I get a similar error even if I minimally set the batch script to only contain a minimal statement. \python.exe -c 'print("Hello")' This implies the problem is something from Python 2 being passed to the Python 3 environment since the Splunk script call is ultimately from that. I asked Splunk support about this and was told it "isn't supported" and was directed to contact professional services which seems like overkill for what is likely just an environment issue. **Is there a way to wrap the python commands such that this still works?** As of now my workaround is to have the batch file called as a scheduled task in Windows and write the results to a file which is then monitored by Splunk. Additionally, at some point Splunk will make the jump internally to Python 3 and likely people will have the reverse problem with older Python 2.X libraries.

Viewing all articles
Browse latest Browse all 47296

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>